mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
21 lines
916 B
HTML
21 lines
916 B
HTML
<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> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<pre><strong>Input:</strong> s = "0110", n = 3
|
|
<strong>Output:</strong> true
|
|
</pre><p><strong>Example 2:</strong></p>
|
|
<pre><strong>Input:</strong> s = "0110", n = 4
|
|
<strong>Output:</strong> false
|
|
</pre>
|
|
<p> </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>
|