PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Instacart

Simulate bus boarding with priority and wheelchairs

Last updated: Mar 29, 2026

Quick Overview

This question evaluates queue and priority handling, stable ordering, capacity accounting, constraint handling for wheelchair riders, and the ability to design unit tests and articulate trade-offs within the Software Engineering Fundamentals category.

  • medium
  • Instacart
  • Software Engineering Fundamentals
  • Software Engineer

Simulate bus boarding with priority and wheelchairs

Company: Instacart

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

You are implementing a simplified bus boarding simulator. Model: - `Person` has at least: - `id` (string/int) - `priority` (boolean): if true, they should board before non-priority riders. - `wheelchair` (optional): if present, the person uses a wheelchair. - `capacityCost` (int): how many capacity units they consume when boarding (defaults to 1 for a normal rider; wheelchair riders may have different costs). - `Bus` has: - `totalCapacity` (int) - `maxWheelchairs = 2` Task A — Priority boarding: - Given a waiting line of people (in arrival order) and a bus with remaining capacity, board as many people as possible. - Priority riders should be boarded before non-priority riders. - Preserve relative order within the priority group and within the non-priority group (stable ordering). - Return (1) the list of boarded riders in the order they boarded and (2) the remaining waiting line. Task B — Explain tradeoffs: - Explain why you implemented it that way. - Provide at least one alternative approach and compare time/space complexity and maintainability. - Mention what you would change for “real production” (e.g., extensibility, fairness/starvation, configurability). Task C — Unit tests: - Write unit tests for Task A (and for Task D below if time). Specify key edge cases. Task D — Add wheelchair constraints: - Extend boarding logic with these rules: - A bus can carry at most 2 wheelchair riders. - Each wheelchair rider consumes `capacityCost` units (not necessarily 1). - Non-wheelchair riders consume 1 unit. - Continue to respect priority boarding and stable ordering within groups. You may define your own function signatures (e.g., `board(bus, waitingQueue)`).

Quick Answer: This question evaluates queue and priority handling, stable ordering, capacity accounting, constraint handling for wheelchair riders, and the ability to design unit tests and articulate trade-offs within the Software Engineering Fundamentals category.

Related Interview Questions

  • Design a bus simulation metric - Instacart (hard)
  • Explain how to understand a large codebase fast - Instacart (hard)
  • Design a task system with assignments - Instacart (medium)
Instacart logo
Instacart
Mar 4, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
23
0

You are implementing a simplified bus boarding simulator.

Model:

  • Person has at least:
    • id (string/int)
    • priority (boolean): if true, they should board before non-priority riders.
    • wheelchair (optional): if present, the person uses a wheelchair.
    • capacityCost (int): how many capacity units they consume when boarding (defaults to 1 for a normal rider; wheelchair riders may have different costs).
  • Bus has:
    • totalCapacity (int)
    • maxWheelchairs = 2

Task A — Priority boarding:

  • Given a waiting line of people (in arrival order) and a bus with remaining capacity, board as many people as possible.
  • Priority riders should be boarded before non-priority riders.
  • Preserve relative order within the priority group and within the non-priority group (stable ordering).
  • Return (1) the list of boarded riders in the order they boarded and (2) the remaining waiting line.

Task B — Explain tradeoffs:

  • Explain why you implemented it that way.
  • Provide at least one alternative approach and compare time/space complexity and maintainability.
  • Mention what you would change for “real production” (e.g., extensibility, fairness/starvation, configurability).

Task C — Unit tests:

  • Write unit tests for Task A (and for Task D below if time). Specify key edge cases.

Task D — Add wheelchair constraints:

  • Extend boarding logic with these rules:
    • A bus can carry at most 2 wheelchair riders.
    • Each wheelchair rider consumes capacityCost units (not necessarily 1).
    • Non-wheelchair riders consume 1 unit.
  • Continue to respect priority boarding and stable ordering within groups.

You may define your own function signatures (e.g., board(bus, waitingQueue)).

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Instacart•More Software Engineer•Instacart Software Engineer•Instacart Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.