Deviopath › Go

Shortest Path

Hard · Algorithms

A directed graph is given as n nodes 0…n-1 and edges [from, to, weight]. Weights are non-negative. Return the shortest distance from src to dst, or -1 if dst is unreachable.

Write Shortest(n, edges, src, dst). A simple O(n²) scan is fine.

Next: Course Order