Skip to content

Commit 43b5649

Browse files
authored
Update second-minimum-time-to-reach-destination.py
1 parent 9deb47a commit 43b5649

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Python/second-minimum-time-to-reach-destination.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ def bi_bfs(adj, start, target):
1717
lookup = set()
1818
result = steps = 0
1919
while left and (not result or result+2 > steps): # modified
20-
for pos in left:
21-
lookup.add(pos)
20+
for u in left:
21+
lookup.add(u)
2222
new_left = set()
23-
for pos in left:
24-
if pos in right:
23+
for u in left:
24+
if u in right:
2525
if not result: # modified
2626
result = steps
2727
elif result < steps: # modifeid
2828
return result+1
29-
for nei in adj[pos]:
30-
if nei in lookup:
29+
for v in adj[u]:
30+
if v in lookup:
3131
continue
32-
new_left.add(nei)
32+
new_left.add(v)
3333
left = new_left
3434
steps += 1
3535
if len(left) > len(right):

0 commit comments

Comments
 (0)