Question
Given a directed weighted graph with n nodes (0..n-1), edges [u, v, w] (non-negative weights), a source src, a destination dst, and an integer K, return the minimum total weight of a path from src to dst that uses AT MOST K edges, or -1 if no such path exists. K may be 0 (then only src reaches itself). Assume 1 <= n <= 500 and K <= n; a layered Bellman-Ford-style relaxation (not plain Dijkstra) is the intended approach.
shortest_path_max_edges(n: int, edges: list[list[int]], src: int, dst: int, K: int) → int[4,[[0,1,100],[1,2,100],[0,2,500],[2,3,100]],0,3,2]out600State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.