leetcode--51. N-Queens

Posted Shihu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode--51. N-Queens相关的知识,希望对你有一定的参考价值。

1、问题描述

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.."]
]

 


以上是关于leetcode--51. N-Queens的主要内容,如果未能解决你的问题,请参考以下文章

leetcode 51. N-Queens N 皇后(困难)

一天一道LeetCode#51. N-Queens

Leetcode51 N-Queens

leetcode--51. N-Queens

LeetCode51 N-Queens

leetCode 51.N-Queens (n皇后问题) 解题思路和方法