Find Binary permutations of given size not present in the Array | C # program for the above approach ; Function to find a Binary String of same length other than the Strings present in the array ; Map all the Strings present in the array ; Find all the subString that can be made ; If num already exists then increase counter ; If not found print ; If all the subStrings are present then print - 1 ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static void findMissingBinaryString ( string [ ] nums , int N ) { HashSet < string > s = new HashSet < string > ( ) ; int counter = 0 ; foreach ( string str in nums ) { s . Add ( str ) ; } int total = ( int ) Math . Pow ( 2 , N ) ; for ( int i = 0 ; i < total ; i ++ ) { string num = " " ; for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( ( i & ( 1 << j ) ) > 0 ) { num += '1' ; } else { num += '0' ; } } if ( s . Contains ( num ) ) { counter ++ ; continue ; } else { Console . Write ( num + " , ▁ " ) ; } } if ( counter == total ) { Console . Write ( " - 1" ) ; } } public static void Main ( string [ ] args ) { int N = 3 ; string [ ] arr = { "101" , "111" , "001" , "011" , "100" , "110" } ; findMissingBinaryString ( arr , N ) ; } }