Instacart·Software Engineer·Technical Phone Screen
- You have a queue of people, each with a priority flag, and a bus with fixed capacity. Priority passengers board first in arrival order, then non-priority fill remaining seats. How would you implement this, and why did you choose that approach over alternatives like a two-queue one-pass strategy?
- How would you adapt this boarding implementation for production use, specifically around thread safety if multiple boarding gates are running concurrently?
- Over a long horizon with repeated boarding events, how would you prevent non-priority passengers from being perpetually starved by priority passengers?
- How would you extend this design to support more than two priority levels?
- What observability or metrics would you add to this system in production, and how would you handle input validation and errors?
- How would you approach testing this boarding system?
“I went with a two-pass partition: first sweep collects priority people, second fills from non-priority up to capacity.”