The N-Queens problem is to place n queens on an n × n chessboard such that no two queens attack each other.
Return all distinct solutions to the N-Queens puzzle. Each solution contains a board configuration represented as an array of strings.
nPrint a JSON array of solutions. Each solution is an array of strings.
Input: 4
Output:
[
[".Q..","...Q","Q...","..Q."],
["..Q.","Q...","...Q",".Q.."]
]
Order of solutions does not matter. Print only the final result.
No submissions yet.
Discuss backtracking, pruning using columns and diagonals.