MakeMyTrip Cheapest Flights Within K Stops
MakeMyTrip Cheapest Flights Within K Stops
MediumGraphs0% accepted
MakeMyTrip has n cities with flights [from, to, price]. Find cheapest price from src to dst with at most k stops. Return -1 if no such route.
Approach
Cheapest flight path with at most K stops (modified Bellman-Ford / BFS).
Input
4 3 0 3 1
0 1 100
1 2 100
2 3 100
Output
-1
More Graphs problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards