Check Whether a Campus Shuttle Can Seat Every Rider Along Its Route
Last updated: November 29, 2026
Quick Overview
A campus shuttle with a fixed seat capacity drives one way along mile markers. Given trips as (riders, pickup_mile, dropoff_mile), return whether it can carry every trip without ever exceeding capacity.
Meta
November 29, 20260
0
0 solved
A campus shuttle with a fixed seat capacity drives one way along mile markers. Given trips as (riders, pickup_mile, dropoff_mile), return whether it can carry every trip without ever exceeding capacity.
A short sweep-line question in the style of a Meta phone screen, set on the shuttles that run between Menlo Park buildings. The interviewer checks whether you see that only the load at pickup and dropoff points matters and that riders leave before new ones board at the same marker.
What the Interviewer Expects
- Clarifies that riders exit at the dropoff marker before others board there
- Turns trips into +riders and -riders events
- Processes events in mile order with exits first on ties
- Stops early once capacity is exceeded
- Mentions a bucket array when miles are small integers
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
- How would you return the first mile where capacity is exceeded?
- What if the shuttle can make multiple loops?
- How would you compute the minimum capacity needed?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: capacity and a list of (riders, pickup, dropoff) with pickup < dropoff. Output: True if the passenger count never exceeds capacity. Riders occupy seats on the half-open stretch [pickup, dro...
High-Level Design
Load only changes at pickups and dropoffs. Emit an event (pickup, +riders) and (dropoff, -riders) for every trip, sort by mile, and for equal miles put the negative deltas first. Walk the events k...