Dsa
Backtracking
Warm-up
N-Queens Arrangement
Given an integer N, return all unique solutions for placing N queens on an N x N chessboard so that no two queens threaten each other. A solution is represented as a list of strings, where 'Q' represents a queen and '.' represents an empty space.
Input format:
- A single integer N (1 <= N <= 9).
Output format:
- A list of solutions represented as lists of strings.
Example:
Input:
4
Output:
[.
Q...
...Q
...Q
...Q,
...Q
Q...
Q...
...]
Key concepts
backtrackingcombinatorics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now