Skip to main content

N-Queens

Place n queens on an n×n chessboard such that no two queens attack each other Return all distinct solutions as board configurations 'Q' = queen, '.' = empty space Example: n = 4 => [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]

N-Queens is about exploring choices without getting lost—choose, recurse, undo, repeat. It's a hard one for a reason: it stresses structured exploration when the rules pile up. The gotcha is duplicates and dead ends—good pruning and ordering rules make this manageable.

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit, and to talk with her for one hour. After that, talking comes with the $79 pack. Anyone can open the editor and run their code.

1Find All N-Queens Solutionshard
Based onLeetCode

Prep guides that list this problem

Our company tags come from public interview write-ups. None of these is a confirmed question.

Get a note when something new lands

New company guides, new problems and big changes to Coco. Rare, and you can leave any time. By joining you agree to get these emails.