Skip to main content
N-Queens | AlgoCracked
AlgoCracked
ProblemsN-Queens
Hard68.0% acceptance
Blind75ArrayBacktracking

N-Queens

The n-queens puzzle asks you to place n chess queens on an n × n board so that no two of them attack each other — no two queens may share a row, a column, or a diagonal. Given n , return every distinct solution. Each solution is a board written as an array of n strings, one string per row, where 'Q' marks a queen and '.' marks an empty square. The solutions may be returned in any order . Input format Input is [n] , e.g. [4] .

Loading workspace…