MEDIUMasked at 21 companies

Gas Station

A medium-tier problem at 46% community acceptance, tagged with Array, Greedy. Reported in interviews at Freecharge and 20 others.

Founder's read

Gas Station shows up in OAs at Flipkart, Oracle, Mastercard, and eight other major companies. It's a medium-difficulty array problem with a 46% acceptance rate, which means nearly half the candidates who attempt it bomb. The trap is obvious: brute force each starting position and simulate the full loop. That works, but it's O(n^2) and slow. The greedy insight is brutal once you see it, invisible before. If this problem hits your live assessment and you blank on the pattern, StealthCoder surfaces the solution in seconds, invisible to the proctor.

Companies asking
21
Difficulty
MEDIUM
Acceptance
46%

Companies that ask "Gas Station"

If this hits your live OA

Gas Station is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The trick is realizing you don't need to test every starting position. Track your fuel as you iterate forward. When fuel goes negative, you know everything before that point can't work as a start. Jump past it and reset. This greedy approach is O(n) and gets you the answer in one pass. Most candidates either code the brute force and time out, or they start reasoning about the problem mathematically and lose time without finding the insight. The Array and Greedy topics are dead giveaways that a single-pass solution exists. If you hit this cold and don't know the trick, StealthCoder runs during screen share and gives you the working code before doubt creeps in.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Gas Station recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Gas Station interview FAQ

Is Gas Station really asked at Oracle and Flipkart?+

Yes. It appears across 21 reported companies, including Oracle, Flipkart, Mastercard, and Zepto. It's a stable fixture in medium-difficulty rounds, especially at fintech and large-scale backend teams.

What's the actual trick?+

When your tank goes negative at position i, you can't start at any position before i. Jump to i+1 and reset. Track total fuel deficit. If total fuel is positive, a valid start exists. That observation collapses O(n^2) to O(n).

Why do so many people fail this?+

The brute force passes small test cases but times out on large arrays. The greedy jump requires proof that you can skip positions safely. Most candidates see 'find starting position' and simulate every one instead of proving only one answer is possible.

Does it matter if I code this in Python or another language?+

No. The algorithm is language-agnostic. Python is fine. The bottleneck is the insight, not syntax or performance micro-tuning. Get the greedy logic right first.

What if I still blank on it during the OA?+

StealthCoder reads the problem off your screen and surfaces a working solution invisible to the proctor. You paste it, explain the greedy idea, and move on. That's what it's there for.

Want the actual problem statement? View "Gas Station" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.