Skip to main content
All Questions

Design an UberShuttle class that seats riders as far from each other as possible.

Unlock detailed company stats for this questionUpgrade

An Uber Shuttle has n seats in a single row, labeled 0 to n - 1. A rider boarding picks the seat that is as far as possible from the nearest rider. If several seats tie, the rider takes the lowest number. If the shuttle is empty, the first rider takes seat 0. Implement the UberShuttle class:

  • UberShuttle(int n): initializes the shuttle with n seats.
  • int board(): returns the seat number where the next rider sits.
  • void dropOff(int p): the rider sitting at seat p leaves the shuttle.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.