Skip to content

Commit baaadf4

Browse files
authored
Update second-minimum-time-to-reach-destination.py
1 parent 777b204 commit baaadf4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ def secondMinimum(self, n, edges, time, change):
6262
:type change: int
6363
:rtype: int
6464
"""
65+
INF = float("inf")
6566
def bfs(adj, start):
6667
q = [start]
67-
dist = {start:0}
68+
dist = [INF]*len(adj)
69+
dist[start] = 0
6870
while q:
6971
new_q = []
7072
for u in q:
7173
for v in adj[u]:
72-
if v in dist:
74+
if dist[v] != INF:
7375
continue
7476
dist[v] = dist[u]+1
7577
new_q.append(v)

0 commit comments

Comments
 (0)