Problem
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return the number of distinct solutions to the n-queens puzzle.
Example:
1 |
|
Explanation
- Similar to 51. N-Queens, but this time we only need to print out the number of result, so we can change the base case to be if all the elements of
corArr
are filled, then we increaseres
and return.
Solution
1 |
|