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)/八皇后 [eight-queens-lcci].html
2022-03-29 12:43:11 +08:00

22 lines
897 B
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>设计一种算法,打印 N 皇后在 N &times; N 棋盘上的各种摆法,其中每个皇后都不同行、不同列,也不在对角线上。这里的&ldquo;对角线&rdquo;指的是所有的对角线,不只是平分整个棋盘的那两条对角线。</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 皇后问题存在如下两个不同的解法。
[
&nbsp;[&quot;.Q..&quot;, &nbsp;// 解法 1
&nbsp; &quot;...Q&quot;,
&nbsp; &quot;Q...&quot;,
&nbsp; &quot;..Q.&quot;],
&nbsp;[&quot;..Q.&quot;, &nbsp;// 解法 2
&nbsp; &quot;Q...&quot;,
&nbsp; &quot;...Q&quot;,
&nbsp; &quot;.Q..&quot;]
]
</pre>