You are coding as a Guest. Sign in with Google in 1 tap to save your daily streak, lock in +50 XP & boost your college rank!
Save Streak (1-Tap Google)9:00 AM Daily Incident ReleaseMaintaining a 7-day streak grants a 2.5× Recruiter Visibility Multiplier on the Recruiter Talent Radar.
Multiplier Ladder:1d: 1.0ו3d: 1.5ו7d: 2.5× MAX
Talent Radar →Problem Set
🔥Network Delay Time: Dijkstra Shortest Path DelayMedium
DAILY PROBLEM OF THE DAY+50 XP • Daily Streak
Solve today's challenge or tackle one of the 3 Super Hard challenges for +150 XP.
MediumTrees & Graphs•Acceptance: 53.6%
Network Delay Time: Dijkstra Shortest Path Delay
Targeted in FAANG & Tech OA:UberGoogleAmazon
Real-World Engineering Context
Core to network packet routing (OSPF protocol), latency SLA analysis across AWS microservices, and Uber ETA calculation algorithms.
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`.
Sample Test Cases
Input: [[[2,1,1],[2,3,1],[3,4,1]],4,2]
Expected: 2
Input: [[[1,2,1]],2,1]
Expected: 1
Input: [[[1,2,1]],2,2]
Expected: -1
Constraints
- 1 <= k <= n <= 100
- 1 <= times.length <= 6000
- times[i].length == 3
- 1 <= ui, vi <= n
- ui != vi
- 0 <= wi <= 100
- All the pairs (ui, vi) are unique.
Verified Proof-of-Work ATS PortfolioCryptographic Verification
Export tamper-proof problem verifications to your direct ATS applications
Every verified problem solve writes authentic cryptographic proof-of-work to your profile. Attach your verified DevScore badge to ATS applications to stand out to engineering hiring teams across 4,000+ verified live tech openings (23,000+ cumulative audited) on RoleNest.
Explore 4,000+ Direct ATS Openings on RoleNest ↗Solve Challenge to Activate Ledger
Language:
Ready to test. Click Run Code or Submit Solution to run test cases in isolated browser sandbox.