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的主要内容,如果未能解决你的问题,请参考以下文章