Implement prototype(n: int, edges: list[tuple[int, int, int]], source: int) -> list[int | None] and solve with the same signature. Vertices are 0..n-1. Directed edges are (u,v,weight) with nonnegative integer weights. Parallel edges, self-loops, and zero weights are valid. Return integer minimum costs in vertex-index order and None for unreachable vertices; source cost is zero.

Example: (3, [(0,1,7),(0,2,2),(2,1,1)], 0) returns [0,3,2].

Raise ValueError for n <= 0, invalid source/endpoints, or any negative edge weight. Prototype: enumerate simple paths. Final: use Dijkstra with a min-heap and stale-entry checks. Preserve inputs, including on failure.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.