Search⌘ K
AI Features

Cheapest Flights Within K Stops

Cheapest Flights Within K Stops asks for the lowest-cost route between two cities, given priced direct flights, while using no more than the allowed number of intermediate stops. Return -1 if none exists.

Statement

You are given n cities, numbered from 00 ...