Fewest Fuel Stops for an Armored Cash Delivery Route

Last updated: November 29, 2026

Quick Overview

An armored truck servicing Capital One ATMs drives a straight route of a given length, burning one fuel unit per mile, and passes stations at known mile markers with known fuel amounts. Return the minimum number of refueling stops needed to finish the route, or -1 if it cannot.

Capital One
Coding & Algorithms
Software Engineer
Capital One
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


An armored truck servicing Capital One ATMs drives a straight route of a given length, burning one fuel unit per mile, and passes stations at known mile markers with known fuel amounts. Return the minimum number of refueling stops needed to finish the route, or -1 if it cannot.

Branch and ATM cash logistics are a real operational cost for a bank with a large physical footprint. This Power Day problem looks for the greedy-with-a-heap insight (decide stops retroactively) and for a candidate who can contrast it with an O(n^2) DP and argue correctness.

What the Interviewer Expects
  • Recognize that stop decisions can be deferred
  • Push every reachable station's fuel into a max-heap
  • Pop the largest fuel only when the truck would otherwise stall
  • Return -1 when the heap is empty before reaching the end
  • Compare with the DP over number of stops
Key Topics to Cover
Greedy
Max-heap
Exchange argument
Dynamic programming alternative
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you return which stations to stop at?
  • If the tank has a maximum capacity, does the greedy still work?
  • How would you minimize total fuel cost when stations charge different prices?
  • How would you extend this to a road network rather than a straight route?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: route length, starting fuel, stations as (mile, fuel) sorted by mile.
  • One fuel unit per mile and an unlimited tank.
  • Output: minimum stops, or -1 if the destination is unreachable....
High-Level Design

Think of fuel as the farthest mile the truck can reach. Every station at or before that mile is one we could have stopped at, so we add its fuel to a max-heap of options. Only when the reach falls s...


Submit Your Answer
Markdown supported