Find any permutation of Binary String of given size not present in Array | Java Program for the above approach ; Function to find a binary string of N bits that does not occur in the givrn array arr [ ] ; Stores the resultant string ; Loop to iterate over all the given strings in a diagonal order ; Append the complement of element at current index into ans ; Return Answer ; Driver code
import java . io . * ; class GFG { static String findString ( String arr [ ] , int N ) { String ans = " " ; for ( int i = 0 ; i < N ; i ++ ) { ans += arr [ i ] . charAt ( i ) == '0' ? '1' : '0' ; } return ans ; } public static void main ( String [ ] args ) { String arr [ ] = { "111" , "011" , "001" } ; int N = arr . length ; System . out . println ( findString ( arr , N ) ) ; } }