N-Queens Solution Count
Problem statement
Place n queens on an n x n chessboard so no two attack one another. Return the number of distinct valid placements.
Function
totalNQueens(n: int) → intExamples
Example 1
n = 4return = 2A four-by-four board has two solutions.
Example 2
n = 1return = 1The single square accepts one queen.
Constraints
1 <= n <= 14.
Source note: Author-written prompt excerpt retained for source fidelity.