일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python Code
- Python Implementation
- Decorator
- DWG
- Regular Expression
- shiba
- iterator
- concurrency
- Generator
- 109. Convert Sorted List to Binary Search Tree
- attribute
- Python
- 밴픽
- 715. Range Module
- t1
- 시바견
- 프로그래머스
- data science
- Class
- kaggle
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 운영체제
- 315. Count of Smaller Numbers After Self
- 파이썬
- LeetCode
- 30. Substring with Concatenation of All Words
- Protocol
- 43. Multiply Strings
- 컴퓨터의 구조
Archives
- Today
- Total
Scribbling
LeetCode: 52. N-Queens II 본문
class Solution:
def totalNQueens(self, n: int) -> int:
self.ret = 0
self.solver(n, [], [], [])
return self.ret
def solver(self, n, queens, sumyx, subyx):
if len(queens) == n:
self.ret += 1
return
for i in range(n):
y, x = len(queens), i
if (i not in queens) and ((y+x) not in sumyx) and ((y-x) not in subyx):
self.solver(n, queens+[i], sumyx+[(y+x)], subyx+[(y-x)])
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 54. Spiral Matrix (1) | 2021.09.17 |
---|---|
LeetCode: 55. Jump Game (0) | 2021.09.15 |
LeetCode: 51. N-Queens (0) | 2021.09.14 |
LeetCode: 10. Regular Expression Matching (0) | 2021.09.14 |
LeetCode: 43. Multiply Strings (0) | 2021.09.13 |