일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- t1
- 715. Range Module
- iterator
- Python
- Generator
- 43. Multiply Strings
- Decorator
- Class
- Convert Sorted List to Binary Search Tree
- Python Implementation
- LeetCode
- DWG
- Substring with Concatenation of All Words
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- 운영체제
- Protocol
- 시바견
- Regular Expression
- data science
- Python Code
- attribute
- concurrency
- kaggle
- 315. Count of Smaller Numbers After Self
- shiba
- 컴퓨터의 구조
- 파이썬
- 30. Substring with Concatenation of All Words
- 프로그래머스
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 |