#3604

Minimum Time to Reach Destination in Directed Graph

specialist · 945 · lc medium +32 · 45.5% accepted · 102 likes · top 29%

Description

A directed graph has n nodes labeled 0 to n - 1. Each edge [ui, vi, starti, endi] may only be traversed at integer time t where starti <= t <= endi.

Begin at node 0 at time 0. Each second you may wait at your current node or traverse an active outgoing edge.

Return the minimum time to reach node n - 1, or -1 if unreachable.

Code

1
2
3