Uber phone screen - Randomly select a driver from a stream of drivers

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-05-23Added By Anonymous
Source: Link

Company: Uber
Role: software engineer i, software engineer ii
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

When user sends a request to Uber ride, the service finds drivers nearby, and sends driver info in the form of a data stream to the application. The application will randomly choose a driver from the stream to pick up this user. Your job is to build a method that will randomly selects a driver from the stream of drivers.

Considering the performance, the application must not load and keep information of all drivers at once. Instead, the method should process one driver after another, and discard previous drivers data when reading the next driver from stream. All drivers have equal chance to be chosen.

Comments