-
Notifications
You must be signed in to change notification settings - Fork 0
/
0052.go
36 lines (32 loc) · 1 KB
/
0052.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Source: https://leetcode.com/problems/n-queens-ii
// Title: N-Queens II
// Difficulty: Hard
// Author: Mu Yang <http://muyang.pro>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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:
//
// https://assets.leetcode.com/uploads/2020/11/13/queens.jpg
//
// Input: n = 4
// Output: 2
// Explanation: There are two distinct solutions to the 4-queens puzzle as shown.
//
// Example 2:
//
// Input: n = 1
// Output: 1
//
// Constraints:
//
// 1 <= n <= 9
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package main
var a000170 = []int{1, 1, 0, 0, 2, 10, 4, 40, 92, 352}
func totalNQueens(n int) int {
return a000170[n]
}