Leetcode-Question-51: N-Queens

原文链接:
https://leetcode.com/problems/n-queens/

题目描述:
51. N-Queens
Difficulty: Hard

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.

8-queens

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

解析:

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注