Question bank › Backtracking
Dsa Backtracking Medium

N-Queens Valid Configuration

Given a number n, find all valid configurations of placing n queens on an n x n chessboard such that no two queens threaten each other. Print each configuration as a grid of 'Q' and '.' characters, with each queen denoted by 'Q' and empty cells by '.'. Each configuration should be printed on a new line, separated by an empty line. Example Input: 4 Example Output: Q... ...Q Q... ...Q ...Q Q... ...Q Q...

Key concepts

backtrackingqueenschess

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.