...

/

Feature #1: Select Closest Drivers

Feature #1: Select Closest Drivers

Description

The first functionality we’ll be building is to locate the nearest available drivers within the vicinity of a user. There are numerous Uber drivers roaming around in a city. For simplicity, we’ll consider the city as a Cartesian plane and assign the coordinates (0, 0) to the user’s location. When a user wants to book a ride, we’ll simply find k drivers with the shortest distance on the Cartesian plane. Here, k is the minimum threshold for choosing the closest drivers.

We’ll be provided a list containing a set of points on the Cartesian plane and a number k. Each set of points will represent the location of a driver. We need to find the k closest drivers from the user’s location.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy