#3620
Network Recovery Pathways
international master · 1990 · lc hard +32 · 29.9% accepted · 136 likes · top 7%
Description
A directed acyclic graph has n nodes (0-indexed) with edges [ui, vi, costi]. Boolean array online marks each node's status; nodes 0 and n - 1 are always online.
A path from 0 to n - 1 is valid when all intermediate nodes are online and the total edge cost does not exceed k. The score of a valid path is its minimum edge cost.
Return the maximum score among all valid paths, or -1 if none exist.
Code
1
2
3