Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Advanced graph algorithms

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Advanced graph algorithms

Network Delay Time

advancedlayer A3 · Advanced graph algorithms5 tests

A network has n nodes labelled 1 to n. Each entry [u, v, w] in times is a directed edge: a signal takes w time to travel from u to v.

A signal is sent from node k. Return the time it takes for all nodes to receive it, or -1 if some node never does.

  • Weights are positive, so this is Dijkstra's algorithm
  • The answer is the largest of the shortest distances
  • JavaScript has no built-in priority queue, so a compact MinHeap keyed on item[0] is already written for you in the starter — write the algorithm, not the plumbing

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen