Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Cheapest Flights Within K Stops

Medium Graphs

Given directed flights (from, to, price), find the cheapest price from src to dst with at most k stops. Print -1 if no route exists.

Constraints

1 <= n <= 100 0 <= m <= n * (n - 1) / 2 0 <= k < n

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.