0052. N-Queens II

https://leetcode.com/problems/n-queens-ii

Description

The n-queens puzzle is the problem of placing n queens on an n x 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:

Example 2:

Constraints:

  • 1 <= n <= 9

ac

https://leetcode.com/problems/n-queens-ii/discuss/20048/Easiest-Java-Solution-(1ms-98.22)

Last updated

Was this helpful?