debug python version, set visited[x][y] to True in the beginning of bfs

This commit is contained in:
HONGYAN ZHAO
2024-10-24 21:08:52 -05:00
parent d64a535938
commit 492f45f53d

View File

@ -254,6 +254,7 @@ directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
def bfs(grid, visited, x, y):
que = deque([])
que.append([x,y])
visited[x][y] = True
while que:
cur_x, cur_y = que.popleft()
for i, j in directions: