update project structure

This commit is contained in:
2024-06-20 06:29:07 +08:00
parent 17b4ef8970
commit fdaa94a0fa
49 changed files with 35 additions and 4 deletions

23
leetcode_py/36.py Normal file
View File

@@ -0,0 +1,23 @@
# Valid Sudoku
class Solution:
def isValidSudoku(self, board: list[list[int]]) -> bool:
rows = [set() for _ in range(9)]
cols = [set() for _ in range(9)]
boxes = [set() for _ in range(9)]
for i in range(9):
for j in range(9):
num = board[i][j]
if num != ".":
box_index = (i // 3) * 3 + j // 3
if num in rows[i] or num in cols[j] or num in boxes[box_index]:
return False
rows[i].add(num)
cols[j].add(num)
boxes[box_index].add(num)
return True