-
Notifications
You must be signed in to change notification settings - Fork 0
/
036.py
29 lines (26 loc) · 968 Bytes
/
036.py
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
class Solution(object):
def isValidSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: bool
"""
for i in range(9):
string = []
for j in range(9):
if board[i][j] != '.' and board[i][j] in string:
return False
string.append(board[i][j])
string = []
for j in range(9):
if board[j][i] != '.' and board[j][i] in string:
return False
string.append(board[j][i])
for i in range(3):
for j in range(3):
string = []
for x in range(i*3, (i+1)*3):
for y in range(j*3, (j+1)*3):
if board[x][y] != '.' and board[x][y] in string:
return False
string.append(board[x][y])
return True