Question
There are n cities (0..n-1) and a list of one-way flights [u, v, w] with positive price w. Find the cheapest price to travel from a source city to a destination city using at most k intermediate stops (so at most k+1 flights). Return the cheapest total price, or -1 if it is unreachable within the stop limit. If source equals destination the price is 0. Constraints: 1 <= n <= 200; 0 <= k <= n.
cheapest_k_stops(n: int, flights: list[list[int]], src: int, dst: int, k: int) → int[3,[[0,1,100],[1,2,100],[0,2,500]],0,2,1]out200State 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.