A bidirectional connected graph consists of n vertices labeled from n. You are given a edges where each edges[i] = [u_i, v_i] represents a bidirectional edge between vertex u_i and vertex v_i. Each pair of vertices is connected by at most
Traversing any edge takes time minutes.
Every vertex has a traffic signal that alternates between green and red simultaneously every change minutes. All signals begin green at time change minutes, back to green at change minutes, and continue alternating indefinitely. You can only depart from a vertex when its signal is green. You may wait at any vertex for any amount of time.
Return the second minimum time in minutes required to travel from vertex n.
Note:
A path is allowed to visit any vertex or cross any edge multiple times.
The second minimum value is defined as the strictly smallest value that is greater than the minimum time.
Constraints:
n
n edges.length n n
edges[i].length
u_i, v_i n
u_i v_i
There are no duplicate edges.
Each vertex can be reached directly or indirectly from every other vertex.
time, change
A bidirectional connected graph consists of n vertices labeled from n. You are given a edges where each edges[i] = [u_i, v_i] represents a bidirectional edge between vertex u_i and vertex v_i. Each pair of vertices is connected by at most
Traversing any edge takes time minutes.
Every vertex has a traffic signal that alternates between green and red simultaneously every change minutes. All signals begin green at time change minutes, back to green at change minutes, and continue alternating indefinitely. You can only depart from a vertex when its signal is green. You may wait at any vertex for any amount of time.
Return the second minimum time in minutes required to travel from vertex n.
Note:
A path is allowed to visit any vertex or cross any edge multiple times.
The second minimum value is defined as the strictly smallest value that is greater than the minimum time.
Constraints:
n
n edges.length n n
edges[i].length
u_i, v_i n
u_i v_i
There are no duplicate edges.
Each vertex can be reached directly or indirectly from every other vertex.
time, change