Skip to content

Commit e745ece

Browse files
authored
Update 815._Bus_Routes.md
1 parent 1c6eb68 commit e745ece

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/Leetcode_Solutions/Python/815._Bus_Routes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ class Solution(object):
5656
for bus in cur_buses:
5757
if bus == T:
5858
return step
59+
5960
for route_idx in bus_in_routes[bus]:
6061
if route_idx not in visited:
6162
visited.add(route_idx)
6263
for new_bus in routes[route_idx]:
6364
if new_bus != bus:
6465
new_buses.append(new_bus)
66+
routes[route_idx] = [] # this line is optional, more efficient if added
6567
cur_buses = new_buses
6668
step += 1
6769
return -1

0 commit comments

Comments
 (0)