<p>Given an array of strings <code>nums</code> containing <code>n</code> <strong>unique</strong> binary strings each of length <code>n</code>, return <em>a binary string of length </em><code>n</code><em> that <strong>does not appear</strong> in </em><code>nums</code><em>. If there are multiple answers, you may return <strong>any</strong> of them</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [&quot;01&quot;,&quot;10&quot;]
<strong>Output:</strong> &quot;11&quot;
<strong>Explanation:</strong> &quot;11&quot; does not appear in nums. &quot;00&quot; would also be correct.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [&quot;00&quot;,&quot;01&quot;]
<strong>Output:</strong> &quot;11&quot;
<strong>Explanation:</strong> &quot;11&quot; does not appear in nums. &quot;10&quot; would also be correct.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [&quot;111&quot;,&quot;011&quot;,&quot;001&quot;]
<strong>Output:</strong> &quot;101&quot;
<strong>Explanation:</strong> &quot;101&quot; does not appear in nums. &quot;000&quot;, &quot;010&quot;, &quot;100&quot;, and &quot;110&quot; would also be correct.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == nums.length</code></li>
	<li><code>1 &lt;= n &lt;= 16</code></li>
	<li><code>nums[i].length == n</code></li>
	<li><code>nums[i] </code>is either <code>&#39;0&#39;</code> or <code>&#39;1&#39;</code>.</li>
	<li>All the strings of <code>nums</code> are <strong>unique</strong>.</li>
</ul>

class Solution {
public:
      void solve(vector<string>& nums,string s,int i,int n,string &ans){
        if(i>=n){
             auto it=find(nums.begin(),nums.end(),s);
         if(it==nums.end() ){
                ans=s;
               
         }
            return ;
        }
         
          s=s+'0';
        
          solve(nums,s,i+1,n,ans);
          s.pop_back();
          s=s+'1';
          solve(nums,s,i+1,n,ans);
          


      }
      string findDifferentBinaryString(vector<string>& nums) {
                int n=nums[0].length();
                string ans="";
                string s="";
                solve(nums,s,0,n,ans);
                return ans;
      }

    // string findDifferentBinaryString(vector<string>& nums) {
    //        unordered_map<string,bool>mp;
    //        int l=nums[0].length();
          
    //        int r=1<<l;
           
    //     //    cout<<r;
    //       for(int i=0;i<r;i++){

             
    //         //   i=(i^(i>>1));
    //           string s="";
    //           int p=l;
    //           int num=i;
    //           while(p>0){
    //                 int a= num&1;
    //               num= num>>1;
    //               string m=to_string(a);
    //               s=m+s;
    //               p--;

    //           }
    //           cout<<s<<" ";
    //           mp[s]=true;

    //        }
    //        for(int i=0;i<nums.size();i++){
           
            
    //             mp[nums[i]]=false;
             
             
    //        }
    //        for(auto it:mp){
    //        cout<< it.first<<" ";
    //         if(it.second){
    //             return it.first;
    //         }
    //        }
    //        return " ";
           
    // }
   

// string findDifferentBinaryString(vector<string>& nums) {
//     unordered_map<string, bool> mp;
//     int l = nums[0].length();

//     int r = 1 << l; // Total number of binary strings of length l

//     for (int i = 0; i < r; i++) {
//         string s = "";
//         int num = i;
//         int p = l;
//         while (p > 0) {
//             int a = num & 1;       // Extract the last bit
//             num = num >> 1;        // Shift right by 1
//             string m = to_string(a);
//             s = m + s;             // Prepend the bit to form the binary string
//             p--;
//         }
//         mp[s] = true;
//     }

//     // Mark given binary strings as false
//     for (int i = 0; i < nums.size(); i++) {
//         mp[nums[i]] = false;
//     }

//     // Find and return the first true binary string
//     for (auto it : mp) {
//         if (it.second) {
//             return it.first;
//         }
//     }

//     return "";
// }



};
186741