Cheapest Flight with at Most K Stops

medium
Unit 9 · Graphs II0/2 to milestone

Given flights (from, to, price) between n cities, find the cheapest price from src to dst using at most k stops (so at most k + 1 flights), or -1.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Cheapest Flight with at Most K Stops · TechGradify