Problem · Array
Minimum Refueling Stops
Learn this problemProblem statement
A car starts at position 0 with startFuel units of fuel and must reach position target. It consumes one unit of fuel per unit of distance.
Each station is [position, fuel]. On reaching a station, the car may stop once and take all of that station's fuel, or skip it. Return the minimum number of stops needed to reach target, or -1 if the target is unreachable.
For this exercise, station positions are distinct and strictly between 0 and target. The input may be unsorted and may be normalized into increasing position order.
Function
minRefuelStops(target: int, startFuel: int, stations: int[][]) → intExamples
Example 1
target = 100startFuel = 10stations = [[10,60],[20,30],[30,30],[60,40]]return = 2Stop at positions 10 and 60. Their fuel is sufficient to reach the target in two stops.
Example 2
target = 100startFuel = 1stations = [[10,100]]return = -1The car cannot reach the station at position 10, so no stop is possible.
Constraints
1 <= target <= 10^90 <= startFuel <= 10^90 <= stations.length <= 2 * 10^5- Each station is
[position, fuel], with distinctpositionstrictly between0andtarget. 1 <= fuel <= 10^9.
More Uber problems
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026