Number of Ways to Arrive at Destination
MediumLeetCodeShortest Paths & Topological Sort
Approach hintTry it first, then revealHide
Run Dijkstra while keeping a path count per node: a strictly shorter distance replaces the count and an equal distance adds to it. Distances exceed 32 bits, and counts are taken modulo 10^9 + 7.