Find any permutation of Binary String of given size not present in Array | C ++ Program for the above approach ; Function to find a binary string of N bits that does not occur in the given 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; string findString ( vector < string > & arr , int N ) { string ans = " " ; for ( int i = 0 ; i < N ; i ++ ) { ans += arr [ i ] [ i ] == '0' ? '1' : '0' ; } return ans ; } int main ( ) { vector < string > arr { "111" , "011" , "001" } ; int N = arr . size ( ) ; cout << findString ( arr , N ) ; return 0 ; }