1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/生成不含相邻零的二进制字符串 [generate-binary-strings-without-adjacent-zeros].html
2024-07-16 16:03:30 +08:00

40 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 18</code></li>
</ul>