Reported July 2026
Uberheap priority queue

Minimum Refueling Stops

Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Uber OA. Under 2s to a working solution.
Founder's read

The Uber OA reported in July 2026 has a Minimum Refueling Stops question, and the trap is the case where you can't reach the next station at all. Most people write a clean loop, pass the two samples, then fail on a hidden test where the car runs dry with no fuel left to grab. The pattern is greedy with a max-heap. You drive as far as you can, and only when you're stuck do you retroactively pick the biggest station you passed. If you blank on that retroactive idea during the assessment, StealthCoder can hand you the working solution while you stay in control of the screen.

The problem

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[][]) → int

Examples
Example 1
target = 100
startFuel = 10
stations = [[10,60],[20,30],[30,30],[60,40]]
return = 2
Stop at positions 10 and 60. Their fuel is sufficient to reach the target in two stops.
Example 2
target = 100
startFuel = 1
stations = [[10,100]]
return = -1
The car cannot reach the station at position 10, so no stop is possible.

Constraints
1 <= target <= 10^9
0 <= startFuel <= 10^9
0 <= stations.length <= 2 * 10^5
Each station is [position, fuel], with distinct position strictly between 0 and target.
1 <= fuel <= 10^9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: don't decide at a station whether to refuel. Just pass it and push its fuel into a max-heap. When your current reach can't get to the next station (or the target), pop the largest fuel from the heap, add it to your reach, and count one stop. If the heap is empty and you're still short, return -1. Sort stations by position first, since the input may be unsorted. Treat the target as a final station with zero fuel so the loop handles it uniformly. The pitfall is the unreachable case. Forgetting to check for an empty heap crashes or returns a wrong count. Also watch startFuel = 0 and overflow in other languages, since reach can hit about 2 * 10^14. Complexity is O(n log n). With 2 * 10^5 stations, a DP over stops at O(n^2) will time out. StealthCoder is your hedge if the heap idea doesn't surface under pressure.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Minimum Refueling Stops cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimum number of refueling stops. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Uber's OA.

Uber reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Refueling Stops FAQ

What's the trick to Minimum Refueling Stops?+

Use a max-heap of fuel amounts from stations you've already passed. Keep driving. When you can't reach the next point, pop the biggest fuel, add it to your range, and count a stop. Greedy works because you only pay for a stop when you're forced to.

Why does my solution fail hidden tests at Uber?+

Usually the unreachable case. If the heap is empty and you still can't reach the next station or the target, you must return -1. Other culprits are unsorted stations, startFuel of 0, and not treating the target as a final checkpoint.

Can I use dynamic programming instead?+

You can. dp[i] holds the farthest distance reachable with i stops. But it's O(n^2), and with up to 2 * 10^5 stations it will likely time out. The heap solution at O(n log n) is the one to write.

Do I need to sort the stations?+

Yes, defensively. The problem says the input may be unsorted and can be normalized into increasing position order. Sort by position first, then run the greedy. Skipping the sort silently breaks the reach logic on shuffled inputs.

How do I prepare for this in 48 hours?+

Write the heap solution from scratch twice. Then test three cases: no stations, startFuel already covers the target, and an unreachable first station. If you can explain why you pop the largest fuel only when stuck, you've got the pattern.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Uber.

OA at Uber?
Invisible during screen share
Get it