Skip to content
Onsite

N-Queens II

HardP3Coding

Return the number of distinct ways to place n queens on an n x n chessboard so that no two queens attack each other. Only the count is needed, not the boards.

Example 1

Input
n = 1
Output
1

Example 2

Input
n = 2
Output
0

Example 3

Input
n = 3
Output
0

Constraints

  • 1 <= n <= 12

Hints

Run checks the 3 visible tests, Submit all 12.