java.lang.Object
g1001_1100.s1016_binary_string_with_substrings_representing_1_to_n.Solution

public class Solution extends Object
1016 - Binary String With Substrings Representing 1 To N.<p>Medium</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;0110&rdquo;, n = 3</p> <p><strong>Output:</strong> true</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;0110&rdquo;, n = 4</p> <p><strong>Output:</strong> false</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 1000</code></li> <li><code>s[i]</code> is either <code>'0'</code> or <code>'1'</code>.</li> <li><code>1 <= n <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • queryString

      public boolean queryString(String s, int n)