题目:
题解:
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
uni = (defaultdict(set), defaultdict(set), defaultdict(set))
for i in range(9):
for j in range(9):
s = board[i][j]
if s == '.': continue
if s in uni[0][i] or s in uni[1][j] or s in uni[2][(i//3)*3 + j//3]: return False
uni[0][i].add(s)
uni[1][j].add(s)
uni[2][(i//3)*3 + j//3].add(s)
return True