-
Notifications
You must be signed in to change notification settings - Fork 0
/
36.py
27 lines (24 loc) · 854 Bytes
/
36.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
class Solution(object):
def isValidSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: bool
"""
row=[[] for i in range(len(board)) ]
column=[[] for i in range(len(board))]
grid=[[] for i in range(len(board))]
for i in range(len(board)):
for j in range(len(board[i])):
if board[i][j]=='.':
continue
if board[i][j] in column[j]:
return False
if board[i][j] in row[i]:
return False
k = i/3+(j/3)*3
if board[i][j] in grid[k]:
return False
row[i].append((board[i][j]))
column[j].append(board[i][j])
grid[k].append(board[i][j])
return True