N Queens

A chess queen attacks every square in its row, its column and both of its diagonals. Return the number of ways to place n queens on an n × n board so that no queen attacks another.

Constraints

  • 1 ≤ n ≤ 11

Example 1

Input
n = 4
Output
2
Why:

Two placements, mirror images of each other.

Example 2

Input
n = 1
Output
1
Why:

One queen on one square.

Hints

    Was this a good challenge?

    Solved by
    0
    Submissions
    0
    Accepted
    –