mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
debug python version, set visited[x][y] to True in the beginning of bfs
This commit is contained in:
@ -254,6 +254,7 @@ directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
|
|||||||
def bfs(grid, visited, x, y):
|
def bfs(grid, visited, x, y):
|
||||||
que = deque([])
|
que = deque([])
|
||||||
que.append([x,y])
|
que.append([x,y])
|
||||||
|
visited[x][y] = True
|
||||||
while que:
|
while que:
|
||||||
cur_x, cur_y = que.popleft()
|
cur_x, cur_y = que.popleft()
|
||||||
for i, j in directions:
|
for i, j in directions:
|
||||||
|
Reference in New Issue
Block a user