Hard

Quiz

#52 N-Queens II

APPROACH

Return the total number of distinct arrangements for placing n non-attacking queens on an n x n chessboard.

Example 1:

Input: n = 4
Output: 2
Explanation: There are two distinct solutions to the 4-queens puzzle as shown.

Example 2:

Input: n = 1
Output: 1
1 of 4
1:00

What is the optimal approach for this problem?