3112. Minimum Time to Visit Disappearing Nodes
There is an undirected graph of
n
nodes. You are given a 2D arrayedges
, whereedges[i] = [ui, vi, lengthi]
describes an edge between nodeui
and nodevi
with a traversal time oflengthi
units.Additionally, you are given an array
disappear
, wheredisappear[i]
denotes the time when the nodei
disappears from the graph and you won’t be able to visit it.Notice that the graph might be disconnected and might contain multiple edges.
Return the array
answer
, withanswer[i]
denoting the minimum units of time required to reach nodei
from node 0. If nodei
is unreachable from node 0 thenanswer[i]
is-1
.
c++
1 |
|