Skip to main content
All Questions

Implement a thread-safe ride sharing system that assigns each passenger one driver.

Unlock detailed company stats for this questionUpgrade

Multiple passengers can request rides and available drivers take them on their journeys. Each passenger must be assigned exactly one driver, and no driver can take more than one passenger at a time. If all drivers are busy, passengers wait and are assigned to the first available driver. Drivers are reassigned immediately after they complete a ride. No two passengers are assigned the same driver simultaneously, and multiple passengers and drivers must interact concurrently without conflicts, with thread safety and no race conditions. Use ExecutorService, manual timeouts to simulate the system, and BlockingQueues and concurrent data structures. Part design, part algorithm.

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.