mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
40 lines
1.3 KiB
HTML
40 lines
1.3 KiB
HTML
<p>给你一个正整数 <code>n</code>。</p>
|
||
|
||
<p>如果一个二进制字符串 <code>x</code> 的所有长度为 2 的<span data-keyword="substring-nonempty">子字符串</span>中包含 <strong>至少</strong> 一个 <code>"1"</code>,则称 <code>x</code> 是一个<strong> 有效</strong> 字符串。</p>
|
||
|
||
<p>返回所有长度为 <code>n</code> 的<strong> 有效</strong> 字符串,可以以任意顺序排列。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">n = 3</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">["010","011","101","110","111"]</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>长度为 3 的有效字符串有:<code>"010"</code>、<code>"011"</code>、<code>"101"</code>、<code>"110"</code> 和 <code>"111"</code>。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">n = 1</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">["0","1"]</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>长度为 1 的有效字符串有:<code>"0"</code> 和 <code>"1"</code>。</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= n <= 18</code></li>
|
||
</ul>
|