N-Queens Count
HardBacktracking
Decode it first. Clues, constraints, pattern and plan before any code.A chess queen attacks any square in the same row, column, or diagonal. Given n, count the number of ways to place n queens on an n by n board so that no two queens attack each other.
n = 4 → 2
n = 1 → 1
n = 3 → 0Constraints
1 <= n <= 9