-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path52.n皇后-ii.py
More file actions
53 lines (50 loc) · 920 Bytes
/
52.n皇后-ii.py
File metadata and controls
53 lines (50 loc) · 920 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# @lc app=leetcode.cn id=52 lang=python
#
# [52] N皇后 II
#
# https://leetcode-cn.com/problems/n-queens-ii/description/
#
# algorithms
# Hard (75.63%)
# Likes: 79
# Dislikes: 0
# Total Accepted: 10.7K
# Total Submissions: 14.1K
# Testcase Example: '4'
#
# n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。
#
#
#
# 上图为 8 皇后问题的一种解法。
#
# 给定一个整数 n,返回 n 皇后不同的解决方案的数量。
#
# 示例:
#
# 输入: 4
# 输出: 2
# 解释: 4 皇后问题存在如下两个不同的解法。
# [
# [".Q..", // 解法 1
# "...Q",
# "Q...",
# "..Q."],
#
# ["..Q.", // 解法 2
# "Q...",
# "...Q",
# ".Q.."]
# ]
#
#
#
# @lc code=start
class Solution(object):
def totalNQueens(self, n):
"""
:type n: int
:rtype: int
"""
# @lc code=end