class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
for i in range(len(board)):
row = []
col = []
for j in range(len(board)):
if board[i][j] != '.' and board[i][j] in row:
return False
else:
row.append(board[i][j])
if board[j][i] != '.' and board[j][i] in col:
return False
else:
col.append(board[j][i])
for i in range(0,len(board),3):
for j in range(0,len(board),3):
temp = []
for k in range(3):
for l in range(3):
data = board[i+k][j+l]
if board[i+k][j+l] != '.' and board[i+k][j+l] in temp :
return False
else:
temp.append(board[i+k][j+l])
return True
댓글남기기