Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
N-Queens
Brute Force
Hash Sets
Bitmask
Standard (4×4)
Custom
n
=
4
4×4 board
try every column permutation, reject diagonal clashes
solutions
0
(none yet)
4×4 board
try every column permutation, reject diagonal clashes
solutions
0
(none yet)
columns = [0, 1, 3, 2]
♛
♛
♛
♛
rows 0 & 1 share a diagonal ✗
solutions
0
(none yet)
columns = [0, 3, 1, 2]
♛
♛
♛
♛
rows 2 & 3 share a diagonal ✗
solutions
0
(none yet)
columns = [1, 0, 3, 2]
♛
♛
♛
♛
rows 0 & 1 share a diagonal ✗
solutions
0
(none yet)
columns = [1, 3, 0, 2]
♛
♛
♛
♛
perm [1,3,0,2] — no diagonal clash ✓
solutions
1
columns = [2, 0, 1, 3]
♛
♛
♛
♛
rows 1 & 2 share a diagonal ✗
solutions
1
columns = [2, 1, 3, 0]
♛
♛
♛
♛
rows 0 & 1 share a diagonal ✗
solutions
2
columns = [3, 0, 1, 2]
♛
♛
♛
♛
rows 0 & 2 share a diagonal ✗
solutions
2
columns = [3, 1, 2, 0]
♛
♛
♛
♛
rows 0 & 3 share a diagonal ✗
solutions
2
4×4 board
2 solutions
solutions
2
Step:
One queen per row and column — try every column permutation.
0 / 26
Standard (4×4)
Custom
n
=
4
0 / 26
Step:
One queen per row and column — try every column permutation.