Minimum refueling stops
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.
Implement
min_refuel_stops(target: int, start_fuel: int, stations: list[list[int]]) → intExamples
in
[100,10,[[10,60],[20,30],[30,30],[60,40]]]out2What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[100,10,[[10,60],[20,30],[30,30],[60,40]]]2not run yetsample