← All problems
N-Queens II (count)
Count the number of distinct ways to place n queens on an n x n chessboard so that no two queens attack each other. Return the count, not the boards themselves.
Complexity
Time O(n!), Space O(n)
Common pitfalls
- Diagonal collision detection wrong
- Counting symmetric duplicates separately is fine
Your solution
Log in to save your code and track progress.