Practice Minimum Time to Visit Disappearing Nodes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Time to Visit Disappearing Nodes
Problem Statement
There is an undirected graph of n nodes. You are given a 2D array edges, where edges[i] = [ui, vi, lengthi] describes an edge between node ui and node vi with a traversal time of lengthi units. Additionally, you are given an array disappear, where disappear[i] denotes the time when the node i disappears from the graph and you won't be able to visit it. Note that the graph might be disconnected and might contain multiple edges. Return the array answer, with answer[i] denoting the minimum units of time required to reach node i from node 0. If node i is unreachable from node 0 then answer[i] is -1.
Source: Minimum Time to Visit Disappearing Nodes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 3, edges = [[0,1,2],[1,2,1],[0,2,4]], disappear = [1,1,5]
[0,-1,4]
# Example 2
n = 3, edges = [[0,1,2],[1,2,1],[0,2,4]], disappear = [1,3,5]
[0,2,3]
# Example 3
n = 2, edges = [[0,1,1]], disappear = [1,1]
[0,-1]
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Time to Visit Disappearing Nodes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.