> For the complete documentation index, see [llms.txt](https://coding-9.gitbook.io/untitled/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coding-9.gitbook.io/untitled/string/general/1980.-find-unique-binary-string.md).

# 1980. Find Unique Binary String

## Problem Statement

<br>

Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return *a binary string of length* `n` *that **does not appear** in* `nums`*. If there are multiple answers, you may return **any** of them*.

&#x20;

**Example 1:**

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

**Example 2:**

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

**Example 3:**

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

&#x20;

**Constraints:**

* `n == nums.length`
* `1 <= n <= 16`
* `nums[i].length == n`
* `nums[i]` is either `'0'` or `'1'`.
* All the strings of `nums` are **unique**.

## Intuition

```
Approach 1: Recursion

Approach 2:
Cantors Daigonal Argument

Take one from each index, only when n string of length n
Flip them we gwt a string which never existed
```

### Links

<https://leetcode.com/problems/find-unique-binary-string/description/>

### Video Links

<https://www.youtube.com/watch?v=o8KyzI4U9M8&ab_channel=AryanMittal>

### Approach 1:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
class Solution {
public:
    string ans = "";
    unordered_map<string, int> mp;
    bool find_ans(int index, int n){
        if(index == n){
            if(mp.find(ans) == mp.end())
                return true;

            return false;
        }

        if( find_ans(index+1, n) )
            return true;

        ans[index] = '1';
        if( find_ans(index+1, n) )
            return true;

        ans[index] = '0';

        return false;
    }

    string findDifferentBinaryString(vector<string>& nums) {
        for(auto &it: nums)
            mp[it]++;

        int n = nums[0].size();

        for(int i=0; i<n; i++)
            ans += "0";

        find_ans(0, n);
        return ans;
    }
};
```

{% endcode %}

### Approach 2:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
class Solution {
public:
    string findDifferentBinaryString(vector<string>& nums) {
        string ans = "";
        
        for(int i =0; i < nums.size(); ++i){
            char curr = nums[i][i];
            ans.push_back(curr == '0'?'1':'0');
        }

        return ans;
    }
};
```

{% endcode %}

### Approach 3:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
```

{% endcode %}

### Approach 4:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
```

{% endcode %}

### Similar Problems

###
