← Instacart Interview Insights

Instacart·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Instacart software engineer round focused entirely on writing unit tests for a priority boarding simulation. Pretty thorough problem with a lot of edge cases to think through, and the discussion around property-based testing was where things got interesting.

Questions Asked (1)

Q1

Write a comprehensive set of unit tests for a priority-boarding bus simulation where priority passengers board first in arrival order, remaining capacity fills with non-priority passengers in arrival order, and the implementation returns both the boarded list and the left-behind list.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The edge cases are where this gets meaty.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the simulation's rules and edge cases, then outline a test plan covering priority ordering, capacity limits, and mixed scenarios. For each test, specify the input queue, expected boarded and left-behind lists, and assert both outputs. Emphasize edge cases like empty queues, all priority, all non-priority, and exact capacity.

Pro tip: Mention that you'd test the order of boarding within each group (priority and non-priority) to ensure arrival order is preserved, and that you'd include a test where priority passengers exceed capacity to verify that only the earliest priority passengers board.

1. Clarify Requirements and Assumptions

Restate the boarding rules: priority passengers board first in arrival order, then non-priority fill remaining capacity in arrival order. Confirm that the function returns both boarded and left-behind lists, and that capacity is a fixed integer.

2. Identify Test Categories

List categories: basic functionality (mixed passengers), edge cases (empty queue, zero capacity, capacity larger than queue), priority-heavy scenarios (more priority than capacity), and non-priority-only scenarios. Also consider order preservation within groups.

3. Design Specific Test Cases

For each category, define concrete inputs and expected outputs. For example: queue with 2 priority and 2 non-priority, capacity 3 → boarded: [P1, P2, N1], left-behind: [N2]. Include a case where priority count exceeds capacity.

4. Write Assertions for Both Outputs

For each test, assert that the boarded list matches the expected order and that the left-behind list contains the remaining passengers in arrival order. Use deep equality checks for lists.

5. Review Coverage and Edge Cases

Ensure tests cover all branches: no priority, no non-priority, exact capacity, over capacity, and empty input. Consider adding a test for duplicate arrival times or stable ordering if applicable.

Key Points to Mention

  • Priority passengers board first in arrival order, then non-priority in arrival order.
  • Capacity is a hard limit; once full, remaining passengers go to left-behind list.
  • Both boarded and left-behind lists must preserve arrival order within their respective groups.
  • Edge cases: empty queue, zero capacity, capacity >= total passengers, all priority, all non-priority.
  • Test that when priority passengers exceed capacity, only the earliest priority passengers board.
  • Use parameterized tests or a table-driven approach to cover multiple scenarios efficiently.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.