← Instacart Interview Insights
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.
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.
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.
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.
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.
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.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.