Question bank › Backtracking
Dsa Backtracking Warm-up

N-Queens Visualizer

You are to implement a solution for the N-Queens problem, where N queens need to be placed on an N x N chessboard so that no two queens threaten each other. For this task, the input will be N, and the queens' placement should be printed as a board of '.' for empty cells and 'Q' for queens. Input Format: - A single integer N (1 ≤ N ≤ 8). Output Format: - Print all unique solutions one after the other, with solutions separated by a blank line. Each board should have rows printed one per line, with each row containing characters. Example: Input: 4 Output: .Q.. ...Q Q... ..Q. ..Q. Q... ...Q .Q..

Key concepts

backtrackingcombinatorial problemsn-queens

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