mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
1.4 KiB
HTML
38 lines
1.4 KiB
HTML
<p>You are given a positive integer <code>n</code>.</p>
|
|
|
|
<p>A binary string <code>x</code> is <strong>valid</strong> if all <span data-keyword="substring-nonempty">substrings</span> of <code>x</code> of length 2 contain <strong>at least</strong> one <code>"1"</code>.</p>
|
|
|
|
<p>Return all <strong>valid</strong> strings with length <code>n</code><strong>, </strong>in <em>any</em> order.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 3</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">["010","011","101","110","111"]</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The valid strings of length 3 are: <code>"010"</code>, <code>"011"</code>, <code>"101"</code>, <code>"110"</code>, and <code>"111"</code>.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 1</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">["0","1"]</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The valid strings of length 1 are: <code>"0"</code> and <code>"1"</code>.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= n <= 18</code></li>
|
|
</ul>
|