Dsa
Backtracking
Medium
N-Queens II
The N-Queens puzzle is the challenge of placing N chess queens on an N×N chessboard such that no two queens threaten each other. Given an integer n, return the number of distinct solutions to the N-Queens puzzle.
Input Format:
A single integer n, the size of the chessboard.
Example Input:
4
Output Format:
An integer representing the number of distinct solutions.
Example Output:
2
Key concepts
backtrackingchessconstraints
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