</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSPractice Problems
DSAHardBacktracking

N-Queens Problem

📋 Problem

Place N queens on an N×N chessboard so that no two queens attack each other (no shared row, column, or diagonal).

🧭 Approach

Use backtracking: try placing a queen in each column of the current row. Before placing, check if it's safe (no conflict with previously placed queens). If safe, place it and recurse to the next row. If a later row has no safe position, backtrack — remove the queen and try the next column in the current row instead.

← Back to all Problems