Fastest Delivery Route With Battery Limits and Swap Stations

Last updated: November 29, 2026

Quick Overview

Given a road-like graph of flight corridors where each edge has a flight time and an integer energy cost, a battery capacity, and a set of nodes where a battery swap restores full charge after a fixed delay, find the minimum time to fly from source to destination without ever running out of energy.

Zipline
Coding & Algorithms
Software Engineer
Zipline
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a road-like graph of flight corridors where each edge has a flight time and an integer energy cost, a battery capacity, and a set of nodes where a battery swap restores full charge after a fixed delay, find the minimum time to fly from source to destination without ever running out of energy.

Long-range Zipline routes can exceed one battery's range, so the planner has to decide where to stop and swap. This tests constrained shortest paths: the candidate should see that time alone is not a sufficient state and build Dijkstra over (node, remaining energy), then reason about the state-space size.

What the Interviewer Expects
  • Identify that (node, battery) is the correct state
  • Model the swap as a self-edge with cost swap_time
  • Prune edges whose energy exceeds remaining charge
  • Argue Dijkstra correctness with non-negative times
  • Bound complexity by V times capacity
  • Discuss reducing state when capacity is large
Key Topics to Cover
Constrained shortest path
Dijkstra
State augmentation
Resource-constrained routing
Graph modelling
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
  • Capacity is 10,000 units; how do you keep the state space manageable?
  • Swap stations have a limited number of charged batteries; what changes?
  • How would you also require arriving with a minimum reserve?
  • How would you return the actual route and swap stops, not just the time?
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

Undirected edges (u, v, minutes, energy) with integer energy. The aircraft starts at src with full charge capacity. Traversing an edge needs energy <= remaining. At a station, a swap takes `sw...

High-Level Design

Two partial routes reaching the same node at different times are not comparable if the faster one has less battery, because the slower one may avoid a swap later. So the state is (node, battery). Ed...


Submit Your Answer
Markdown supported

Related Questions