<p>Given a binary string <code>s</code> and a positive integer <code>n</code>, return <code>true</code><em> if the binary representation of all the integers in the range </em><code>[1, n]</code><em> are <strong>substrings</strong> of </em><code>s</code><em>, or </em><code>false</code><em> otherwise</em>.</p>

<p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "0110", n = 3
<strong>Output:</strong> true
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "0110", n = 4
<strong>Output:</strong> false
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 1000</code></li>
	<li><code>s[i]</code> is either <code>&#39;0&#39;</code> or <code>&#39;1&#39;</code>.</li>
	<li><code>1 &lt;= n &lt;= 10<sup>9</sup></code></li>
</ul>

/*

binary representation of all integers in range 1 .. 2^31

that means 31 bits

input has length of max 1000

lets say n = 1
1

n = 2
1
10

n = 3
01 
10
11

3 bits - 
101
110
111


input should be like 110, or 11011 or 11101

check if all 31 bits combinations are present

eg - check if all 15 bits combinations are present


convert n to its binary format
eg 3 = 
11

a string with a length of 1000 will have how many substring ? 
1000 * 1000 substrings ie 10^6 substring

we don't even need to check substring > 31 length
so basically
1000 * 32 * 32

store them using brute force
and check check if all numbers are formed or not

*/
class Solution {
public:
    bool queryString(string s, int n) {
        unordered_set<int> covered;
        for (int i = 0; i < s.size(); i++) {
            int value = 0;
            for (int j = 1; j < 32 && i + j - 1 < s.size(); j++) {
                value = (value << 1) | (s[i + j - 1] - '0');
                covered.insert(value);
            }
        }
        if (covered.size() < n) return false;
        for (int i = 1; i <= n; i++) {
            if (!covered.contains(i)) return false;
        }
        return true;
    }
};
14600