Minimum refueling stops
Your task
A car starts with start_fuel liters and wants to reach a destination target miles away (1 mile costs 1 liter). Along the way there are gas stations given as [position, fuel], meaning at that mile-marker the car can pick up that many liters. The tank is unlimited. Return the minimum number of refueling stops needed to reach the target, or -1 if it cannot reach it. Stations are sorted by position and there are at most 500 of them.
Examples
min_refuel_stops(target: int, start_fuel: int, stations: list[list[int]]) -> intExample 1
Input
min_refuel_stops(100, 10, [[10, 60], [20, 30], [30, 30], [60, 40]])Output
2