// N-Queens II — HARD
// Category: backtracking
The N-Queens puzzle places `n` queens on an `n x n` chess board so that no two queens attack each other. Given an integer `n`, return the number of distinct solutions.
Hint: Backtracking. For each row, try placing a queen in each column. Use three sets to track which columns, and which diagonals (`row - col` and `row + col`) are already occupied. Count the arrangements where all `n` rows have been placed.
Example: n = 4
Output: 2