size queens on a size × size chessboard so that none of them can capture another: no two queens may share a row, a column or a diagonal.
Return every such arrangement. An arrangement is a list of size strings of length size, one string per board row from top to bottom; a square with a queen is marked 'Q' and an empty square is marked '.'.
If there are no arrangements, return an empty list. The arrangements may be returned in any order.size=4 → [['.Q..', '...Q', 'Q...', '..Q.'], ['..Q.', 'Q...', '...Q', '.Q..']]
A 4 × 4 board has exactly two arrangements in which no two queens attack each other.
size=3 → []
On a 3 × 3 board some two of the three queens always attack each other, so there are no arrangements.
size=1 → [['Q']]
size ≤ 9size=4
[['.Q..', '...Q', 'Q...', '..Q.'], ['..Q.', 'Q...', '...Q', '.Q..']]
Run checks the first 3 tests in your browser. Submit checks all 11 tests on the server, hidden ones included.