码迷,mamicode.com
首页 > 其他好文 > 详细

51. N-Queens

时间:2017-07-24 19:04:18      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:ica   hat   turn   tac   where   space   sbo   amp   ble   

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.



Given an integer n, return all distinct solutions to the n-queens puzzle.

Each solution contains a distinct board configuration of the n-queens placement, where Q and . both indicate a queen and an empty space respectively.

For example,
There exist two distinct solutions to the 4-queens puzzle:

[
 [".Q..",  // Solution 1
  "...Q",
  "Q...",
  "..Q."],

 ["..Q.",  // Solution 2
  "Q...",
  "...Q",
  ".Q.."]
]

 

51. N-Queens

标签:ica   hat   turn   tac   where   space   sbo   amp   ble   

原文地址:http://www.cnblogs.com/apanda009/p/7230107.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!