🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 21 - Shortest PathsPractice QuestionsOverview

Shortest Paths Practice Questions

Eight interview classics covering every algorithm in the chapter. Each problem is a direct instance of BFS, Dijkstra, Bellman-Ford, or Floyd-Warshall — once you recognize which one, the code writes itself.

Before reading any solution, force yourself through the decision flow:

  1. Equal weights? → BFS
  2. Single source, non-negative? → Dijkstra
  3. Negative edges? → Bellman-Ford
  4. All pairs, small V? → Floyd-Warshall
  5. Constraint on edge count? → modified Bellman-Ford / expanded-state Dijkstra

Five questions. Four algorithms. The whole chapter.

Easy

ProblemPatternStatus
Network Delay TimeDijkstra → take max distanceAvailable
Shortest Path in Binary MatrixBFS on an implicit 8-connected gridAvailable

Medium

ProblemPatternStatus
Cheapest Flights Within K StopsBellman-Ford limited to K+1 passes (or expanded Dijkstra)Available
Path with Minimum EffortModified Dijkstra — replace sum with maxAvailable
Find City With Smallest Number of NeighborsFloyd-Warshall all-pairsAvailable
The Maze IIDijkstra on a grid with “rolling ball” edge weightsAvailable

Hard

ProblemPatternStatus
Word LadderBFS on an implicit string-mutation graphAvailable
Swim in Rising WaterDijkstra-style minimax on a gridAvailable

More Practice (Coming Soon)

ProblemPatternStatus
Shortest Path Visiting All NodesBitmask BFSComing Soon
Reachable Nodes In Subdivided GraphDijkstra + edge subdivisionComing Soon
Bus RoutesBFS over routes-as-verticesComing Soon
Minimum Cost to Reach Destination in TimeConstrained DijkstraComing Soon
Number of Ways to Arrive at DestinationDijkstra + path countingComing Soon
Minimum Number of Refueling StopsDijkstra-flavored DPComing Soon
Currency ArbitrageBellman-Ford negative cycle detectionComing Soon
Second Minimum Time to Reach NodeModified Dijkstra tracking two best distancesComing Soon