1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-13 01:15:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -1,21 +1,22 @@
<p>设计一种算法,打印 N 皇后在 N &times; N 棋盘上的各种摆法,其中每个皇后都不同行、不同列,也不在对角线上。这里的&ldquo;对角线&rdquo;指的是所有的对角线,不只是平分整个棋盘的那两条对角线。</p>
<p>设计一种算法,打印 N 皇后在 N × N 棋盘上的各种摆法,其中每个皇后都不同行、不同列,也不在对角线上。这里的“对角线”指的是所有的对角线,不只是平分整个棋盘的那两条对角线。</p>
<p><strong>注意:</strong>本题相对原题做了扩展</p>
<p><strong>示例:</strong></p>
<p><strong>示例</strong></p>
<pre><strong> 输入</strong>4
<strong></strong>[[&quot;.Q..&quot;,&quot;...Q&quot;,&quot;Q...&quot;,&quot;..Q.&quot;],[&quot;..Q.&quot;,&quot;Q...&quot;,&quot;...Q&quot;,&quot;.Q..&quot;]]
<strong> 解释</strong>: 4 皇后问题存在如下两个不同的解法。
<pre>
<strong></strong>4
<strong> 输出</strong>[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
<strong> 解释:</strong>4 皇后问题存在如下两个不同的解法。
[
&nbsp;[&quot;.Q..&quot;, &nbsp;// 解法 1
&nbsp; &quot;...Q&quot;,
&nbsp; &quot;Q...&quot;,
&nbsp; &quot;..Q.&quot;],
&nbsp;[".Q..", &nbsp;// 解法 1
&nbsp; "...Q",
&nbsp; "Q...",
&nbsp; "..Q."],
&nbsp;[&quot;..Q.&quot;, &nbsp;// 解法 2
&nbsp; &quot;Q...&quot;,
&nbsp; &quot;...Q&quot;,
&nbsp; &quot;.Q..&quot;]
&nbsp;["..Q.", &nbsp;// 解法 2
&nbsp; "Q...",
&nbsp; "...Q",
&nbsp; ".Q.."]
]
</pre>