Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · DSA · Worked problems, in English · about 19 min to read

Play it as a journeyTutor comes with a plan

Clinic #25: Network Delay Time

Pattern: Graphs / Dijkstra · LC 743

Shortest Path Traced
Shortest Path Traced · Open board

Five towns joined by one-way roads, a travel time on every road, and the earliest arrival written beside each town. This clinic uses that same five-point map, drawn as a table of falling dominoes.

Before you start. You need a list, and the habit of keeping a running smallest number while you read it. Dots joined by lines (a graph) are introduced in Graphs (BFS, DFS, Dijkstra, topological sort), and Shortest Paths, Worked (Dijkstra, Bellman-Ford, A*) traces this same map three ways. Neither is needed first, because everything below is built by hand from one small table.

Lesson 64 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • May 1979: the ARPANET starts timing its own wires
  • LeetCode 743: the same question, as a list of wires
  • A table of dominoes: the question you can watch
  • The wrong first idea: count the lines
  • A node falls once, at its shortest path time
  • Dijkstra’s algorithm: always handle whichever node falls next
  • The priority queue: a pile that always hands back the earliest
  • Solution ladder
  • The trace, printed
  • Measured: where each one loses
  • The bug that passes the sample
  • Interview path, first time
  • The tell
  • The ladder for this pattern

Terms it explains: LC 743, node, edge, shortest path, Dijkstra's algorithm, priority queue, Dijkstra + heap, O(E log n), write this one, plus, Path with Maximum Probability.

Review DSA