52. N Queens II

Practice N Queens II for free on NudgeCode: Hard, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return how many ways there are to place n queens on an n x n chess board so that no two queens share a row, a column or a diagonal.

Example

n = 4  ->  2
n = 1  ->  1

Constraints