일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 Implementation
- Python
- iterator
- attribute
- LeetCode
- concurrency
- Class
- Convert Sorted List to Binary Search Tree
- DWG
- 30. Substring with Concatenation of All Words
- 715. Range Module
- Generator
- Substring with Concatenation of All Words
- Decorator
- t1
- 밴픽
- 운영체제
- 109. Convert Sorted List to Binary Search Tree
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- Python Code
- data science
- Protocol
- kaggle
- 파이썬
- Regular Expression
- 43. Multiply Strings
- shiba
- 시바견
Archives
- Today
- Total
Scribbling
36. Valid Sudoku 본문
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
for i in range(9):
for j in range(9):
if board[i][j] != '.':
# 가로
for k in range(9):
if k == j:
continue
if board[i][j] == board[i][k]:
return False
# 세로
for k in range(9):
if k == i:
continue
if board[i][j] == board[k][j]:
return False
# 사각형
start_y = i // 3 * 3
start_x = j // 3 * 3
for y in range(start_y, start_y+3):
for x in range(start_x, start_x + 3):
if y == i or x == j:
continue
if board[i][j] == board[y][x]:
return False
return True
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 40. Combination Sum II (0) | 2021.09.07 |
---|---|
37. Sudoku Solver (0) | 2021.09.06 |
44. Wildcard Matching (0) | 2021.09.06 |
LeetCode: 48. Rotate Image (0) | 2021.09.05 |
39. Combination Sum (0) | 2021.09.04 |