Question bank › Backtracking
Dsa Backtracking Medium

N-Queens Configuration

You are tasked with placing N queens on an N x N chessboard so that no two queens threaten each other. Write a function to return all distinct configurations of N-Queens solutions. Each configuration should be represented as a list of strings, where each string represents a row of the chessboard with '.' indicating an empty square and 'Q' indicating a queen. Input format: A single integer N. Output format: A list of configurations. Example: Input: 4 Output: ['.Q..', '...Q', 'Q...', '..Q.']

Key concepts

backtrackingrecursioncombinatorics

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.