The N-Queens problem asks you to place n queens on an n x n chessboard so that no two queens attack each other — meaning no two queens share the same row, column, or diagonal.
Your task is to return all distinct solutions to this puzzle.
Each solution should be represented as an array of strings, where:
'Q' represents a queen
'.' represents an empty space
You may return the solutions in any order.
Input: n = 4
Output: [[".Q..","...Q","Q...","..Q."], ["..Q.","Q...","...Q",".Q.."]]
Explanation:
There exist two distinct arrangements for placing 4 queens.
Input: n = 1
Output: [["Q"]]
Accepted:
Submission: