As reported: eBay Staff Software Engineer (AI Platform), DSA round (2026): backtracking, including N-Queens, with follow-ups involving knights. Also asked in an eBay SWE III round (2025, coding on CodeSignal).
Place n queens on an n × n board so that no two attack each other (no shared row, column or diagonal). Return all distinct solutions; each solution is a list of n strings where 'Q' is a queen and '.' an empty square.
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 prints the list of boards.