Practice Network Delay Time
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Network Delay Time
Problem Statement
You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target. We will send a signal from a given node k. Return the minimum time it takes for all the n nodes to receive the signal. If it is impossible for all the n nodes to receive the signal, return -1.
Source: Network Delay Time on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
2
# Example 2
times = [[1,2,1]], n = 2, k = 1
1
# Example 3
times = [[1,2,1]], n = 2, k = 2
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Network Delay Time.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.