dsa · hard

N Queens II

Return how many ways you can place n queens on an n × n board so that no two share a row, a column, or a diagonal. You do not need the drawings, only the count.

Arguments

Example

n = 4 has 2 placements (the two drawings of the companion board problem).

n = 11. n = 2 and n = 30.

Constraints

1 <= n <= 9

Examples

Example 1

Input:
4

Expected:
2

Example 2

Input:
1

Expected:
1

Open in the Dojo editor