Simulate FIFO Order Dispatch Across a Shared Drone Fleet
Last updated: November 29, 2026
Quick Overview
A hub has drones that each become available at a known time, and a FIFO queue of orders with a creation time, a pick-and-pack time and a round-trip flight time. Assign each order to the earliest available drone and return its launch time and drone id.
Zipline
November 29, 20260
0
0 solved
A hub has drones that each become available at a known time, and a FIFO queue of orders with a creation time, a pick-and-pack time and a round-trip flight time. Assign each order to the earliest available drone and return its launch time and drone id.
Zipline's dispatch problem shows up in a simplified form: orders arrive, someone packs them, and the next free aircraft flies them. The interviewer wants a heap-based simulation, clear handling of the wait between an order being ready and a drone being free, and tie-breaking that is stated rather than accidental.
What the Interviewer Expects
- Model each order's ready time as created plus prep
- Use a min-heap keyed by drone free time
- Launch at the max of drone free time and order ready time
- State a deterministic tie-break (lowest drone id)
- Discuss why FIFO can be suboptimal and what you would change
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Orders now have delivery deadlines; how would you minimise missed deadlines?
- Drones need a fixed recharge or battery swap between flights; where does that go?
- How would you compute the average wait time per order and the drone utilisation?
- Some orders are too heavy for some aircraft; how does the data structure change?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: drone_ready[i] the time drone i is first free; orders as (created, prep, round_trip) in queue order. Orders are served strictly FIFO. Each order goes to the drone that frees up earliest ...
High-Level Design
Keep a min-heap of (free_at, drone_id). For each order, pop the earliest drone, launch at max(free_at, created + prep), then push the drone back with launch + round_trip. Because orders are FIFO...