Hard
Quiz
#51 N-Queens
APPROACH
Place n non-attacking queens on an n x n chessboard and return all distinct valid board layouts, using 'Q' for a queen and '.' for an empty cell.
Example 1:
Input: n = 4
Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above
Example 2:
Input: n = 1
Output: [["Q"]]
1 of 4
1:00
What is the optimal approach for this problem?