51. N-Queens
Hard — Backtracking
Backtracking + Sets
Bitmask
Brute (Permutations)
Board size n:
4
5
6
7
8
9
Apply
Play
Pause
Step
Reset
Speed:
Slow
Normal
Fast
Very Fast
Press "Play" or "Step" to walk through the search.
Step
0 / 0
Placements
0
Backtracks
0
Solutions Found
0
Trying
Queen placed
Solution row
Attacked
Current row
Algorithm Complexity (smaller bar = faster)
Brute Permutations
O(n! · n²)
Time / Space: O(n!·n²) / O(n)
Backtracking + Sets
O(n!) pruned
Time / Space: O(n!) / O(n)
Backtracking + Bitmask
O(n!) bitwise
Time / Space: O(n!) / O(n)