Random Weighted Driver

Start Timer

0:00:00

Upvote
12
Downvote
Save question
Mark as completed
View comments (13)

Let’s say we want to improve the matching algorithm for drivers and riders for Uber. The engineering team has added a new column to the drivers table called weighting. It contains a weighted value, which they hope will lead to better matching.

Given this table of drivers, write a query to perform a weighted random selection of a driver based on the driver weight.

Example:

Input:

drivers table

Column Type
id INTEGER
weighting INTEGER

Output:

Column Type
id INTEGER
.
.
.
.
.


Comments

Loading comments