Skip to main content

N-Queens

Learn N-Queens (Recursion & Backtracking, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Placing N Queens So None Attack Each Other Place N queens on an N×N board with no two sharing a row, column, or diagonal. Since each ROW must have exactly one queen, the recursion places one queen per row, checking column and diagonal safety before committing - a textbook backtracking problem.

More lessons in Recursion & Backtracking