mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			897 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			897 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>设计一种算法,打印 N 皇后在 N × N 棋盘上的各种摆法,其中每个皇后都不同行、不同列,也不在对角线上。这里的“对角线”指的是所有的对角线,不只是平分整个棋盘的那两条对角线。</p>
 | 
						||
 | 
						||
<p><strong>注意:</strong>本题相对原题做了扩展</p>
 | 
						||
 | 
						||
<p><strong>示例:</strong></p>
 | 
						||
 | 
						||
<pre><strong> 输入</strong>:4
 | 
						||
<strong> 输出</strong>:[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
 | 
						||
<strong> 解释</strong>: 4 皇后问题存在如下两个不同的解法。
 | 
						||
[
 | 
						||
 [".Q..",  // 解法 1
 | 
						||
  "...Q",
 | 
						||
  "Q...",
 | 
						||
  "..Q."],
 | 
						||
 | 
						||
 ["..Q.",  // 解法 2
 | 
						||
  "Q...",
 | 
						||
  "...Q",
 | 
						||
  ".Q.."]
 | 
						||
]
 | 
						||
</pre>
 |