As reported: NetApp SSE, loop · DSA round (2026): about 20 minutes of behavioral questions, then N-Queens.
Place n queens on an n × n chessboard so that no two queens attack each other — no two share a row, a column or a diagonal. Return all distinct solutions. Each solution is a board: a list of n strings where 'Q' is a queen and '.' an empty square. Any order of the solutions is accepted.
This is LeetCode 51 — N-Queens.
Example 1
n = 4 -> [["..Q.","Q...","...Q",".Q.."], [".Q..","...Q","Q...","..Q."]]
Example 2
n = 1 -> [["Q"]]
Constraints: 1 ≤ n ≤ 9.
Code runner format: one line: n. Implement solveNQueens(n); the harness sorts the boards before printing, so any order is accepted.