class Solution(object):
def isValidSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: bool
"""
flag = True
n = len(board)foriin range(n):
temp =[]forjin range(n):
if board[i][j]==".":continue# 执行完continue后,下面的代码将不执行,继续执行for循环体的下一个jif board[i][j] not in temp:
temp.append(board[i][j])
else:
flag = False
return flag
foriin range(n):
temp =[]forjin range(n):
if board[j][i]==".":continueif board[j][i] not in temp:
temp.append(board[j][i])
else:
flag = False
return flag
foriin range(0, n, 3):
forjin range(0, n, 3):
temp =[]forxin range(0, 3):
foryin range(0, 3):
if board[i+x][j+y]==".":continueif board[i+x][j+y] not in temp:
temp.append(board[i+x][j+y])
else:
flag = False
return flag
return flag