Algorithms

N-queens

The problem of placing n chess queens on an n × n board so that none attacks another: not in the same row, the same column or the same diagonal.

Example

With 4 queens on a 4 × 4 board there are exactly 2 solutions; with 8 on an 8 × 8 board, there are 92.

Test yourself: N-queens

N-queens

2 queens cannot share a row, a column or a ___.

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.