Description
The n-queens puzzle is the problem of placing n queens on an n x 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 where 'Q' indicates a queen and '.' indicates an empty space.
Examples
Input:
n = 4Output:
[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]Explanation:
There exist two distinct solutions to the 4-queens puzzle.
Input:
n = 1Output:
[["Q"]]Explanation:
Single queen on 1x1 board.
Input:
n = 2Output:
[]Explanation:
Edge case with empty result.
Constraints
- •
1 ≤ n ≤ 9