Lyft logo

Lyft Interview Questions

15 practice questions for Lyft technical interviews

Lyft software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Restaurant Delivery Network


Category: String coding problem
You are building a food discovery platform. Given a user's location, a list of restaurants with their coordinates, and a menu of items with prices,...
Input: List
Output: Computed result
coding Medium Verified Question #2

2. Worker Task Scheduler


Category: String coding problem
You are given a list of tasks sorted by start time. Each task is represented as a three-element list [task_id, start_time, duration], where...
Input: List
Output: Array
coding Medium Verified Question #3

3. Paged Data Reader


Category: Trie-based coding problem
You have an external data source that serves records in fixed pages. The data source is represented as a list of pages, where each page is a list of...
Input: Array of strings
Output: Computed result
coding Medium Verified Question #4

4. Multi-Source Reader


Category: String coding problem
Implement a MultiSource class that manages a collection of character sources. Each source is a string of characters. You can add and remove sources...
Input: String
Output: Printed output
coding Hard Verified Question #5

5. Transactional Cache


Category: String coding problem
Implement an in-memory key-value cache that supports nested transactions. The cache stores string keys mapped to string values and provides the...
Input: String
Output: Computed result
coding Hard Verified Question #6

6. Probe Collision Simulator


Category: Algorithm coding problem
A set of probes is arranged in a line from left to right. Each probe has a mass and a velocity. A positive velocity means the probe moves to the...
Input: List
Output: Computed result
coding Medium Verified Question #7

7. Range Coverage Tracker


Category: Interval-based coding problem
You are painting a road of total length n. Each paint stroke starting at position x covers the segment [x, x + 1]. Implement a RangeTracker...
Input: Given input
Output: Computed result
coding Hard Verified Question #8

8. Log Query Engine


Category: String coding problem
You are given a collection of log records. Each record is a five-element list of strings: [time, id, user, type, value], where time and value...
Input: Array of strings
Output: Computed result
coding Medium geometry #1

1. Coding — Find optimal ride-sharing pairs

Background: Lyft connects drivers with riders in real time. While matching these pairs, it is essential to minimize waiting times and maximize ride efficiency.
Problem statement: You are given a list of n riders, where each rider has a unique identifier along with their pickup and drop-off locations represented as point coordinates. The goal is to find the optimal k pairs of riders that can share a ride based on the smallest total distance traveled, where the distance is calculated using the Euclidean distance formula. Return a list of pairs of rider IDs.
Function/class signature:
  • def find_optimal_pairs(riders: List[Tuple[int, Tuple[int, int]]], k: int) -> List[Tuple[int, int]]:

Example 1:
  • Input: riders = [(1, (1, 2)), (2, (2, 3)), (3, (4, 6)), (4, (10, 12))], k = 2

  • Output: [(1, 2), (3, 4)]

  • Explanation: The pair (1, 2) and (3, 4) have the smallest total distances among all possible combinations.

Example 2:
  • Input: riders = [(1, (0, 0)), (2, (1, 1)), (3, (2, 2)), (4, (3, 3))], k = 1

  • Output: [(1, 2)]

Constraints:
  • 1 ≤ n ≤ 1000 (number of riders)

  • 1 ≤ kn (number of pairs)

  • Each coordinate is between -10^4 and 10^4.
coding Medium hash map #2

2. CODING — Find Missing Driver in a Ride Matching System

Background: Lyft's driver-rider matching service relies on efficient allocation of drivers to riders in real-time. Identifying missing drivers in specific scenarios can help improve system efficiency and rider satisfaction.
Problem statement: Given a list of drivers available for matched rides and a list of completed_rides which includes driver identifiers, your task is to find the driver identifiers who are available but not included in the completed_rides. The function should return a list of these missing drivers.
Function/class signature:
  • def find_missing_drivers(drivers: List[int], completed_rides: List[int]) -> List[int]:

Example 1:
  • Input: drivers = [1, 2, 3, 4]

  • completed_rides = [1, 2]

  • Output: [3, 4]

  • Explanation: Drivers 3 and 4 have not completed any rides.

Example 2:
  • Input: drivers = [5, 6, 7, 8]

  • completed_rides = [5, 8, 6]

  • Output: [7]

  • Explanation: Driver 7 is available but has not completed any rides.

Constraints:
  • 1 <= len(drivers), len(completed_rides) <= 1000

  • Driver identifiers are unique integers.

coding Medium dynamic programming #3

3. Dynamic Programming — Minimum Ride Cost Calculation

Background: Lyft needs to efficiently calculate the minimum cost for a rider based on the distance, time, and pricing tiers for rides. As the demand for on-demand transport increases, rideshare companies face the challenge of providing cost-effective estimates for users.
Problem statement: You are tasked with implementing a function to compute the minimum ride cost for a rider. The function should take an array of ride options, each with a distance, time, and cost per mile, and return the minimum total cost for a given distance and time. The pricing structure may vary based on the ride type.
Function/class signature:
  • def minimum_ride_cost(ride_options: List[Tuple[int, int, float]], distance: int, duration: int) -> float:

Example 1:
  • Input: ride_options = [(2, 5, 3.0), (3, 8, 2.5)], distance = 10, duration = 30

  • Output: 25.0,

  • Explanation: For the first ride option, the cost would be 2 * 10 + 5 * 30 = 25.0.

Example 2:
  • Input: ride_options = [(1, 2, 1.0), (4, 5, 1.5)], distance = 6, duration = 10

  • Output: 15.0,

  • Explanation: The second ride option gives a total cost of 4 * 6 + 5 * 10 = 15.0.

Constraints:
  • 1 <= len(ride_options) <= 100

  • 1 <= distance <= 1000

  • 1 <= duration <= 1000

  • 0 < cost per mile <= 10
coding Medium graph #4

4. [Graph] — Implement a driver-rider matching algorithm

Background: Lyft operates a real-time service that matches riders with nearby drivers. Efficient matching is crucial for providing quick pickups, optimizing driver routes, and enhancing overall user satisfaction.
Problem statement: You need to implement a function that simulates a simplified version of the driver-rider matching process. Given a list of drivers' locations and riders' locations, the function should find the nearest driver for each rider. The distance between two points can be calculated using the Euclidean distance formula. You should return a list of pairs, where each pair consists of a rider and their matched driver.
Function/class signature:
  • def match_riders_with_drivers(drivers: List[Tuple[float, float]], riders: List[Tuple[float, float]]) -> List[Tuple[Tuple[float, float], Tuple[float, float]]]:

Example 1:
  • Input: drivers = [(1, 1), (2, 2), (3, 3)], riders = [(2, 1), (1, 3)]

  • Output: [((1, 1), (2, 1)), ((2, 2), (1, 3))]

  • Explanation: The rider at (2, 1) is closest to the driver at (1, 1), and the rider at (1, 3) is closest to the driver at (2, 2).


Example 2:
  • Input: drivers = [(0, 0), (5, 5)], riders = [(2, 2), (8, 8)]

  • Output: [((0, 0), (2, 2)), ((5, 5), (8, 8))]

  • Explanation: The rider at (2, 2) can only be matched to the driver at (0, 0) because it's closer.


Constraints:
  • 1 ≤ len(drivers), len(riders) ≤ 10^4

  • Driver and rider coordinates are within the range of (-10^5, 10^5)
coding Medium geolocation #5

5. Coding — Driver Rider Matching Algorithm


Background: Lyft needs an efficient way to match riders with drivers based on proximity and availability to ensure a quick and reliable service for users. This problem is crucial as it directly impacts the user experience of the Lyft application.
Problem statement: Given a list of drivers with their current locations as (lat, lon) and a list of riders with their pickup locations, implement a function to match each rider with the nearest available driver. You should return a list of pairs indicating which driver has been assigned to each rider. Assume each driver can serve only one rider at a time.
Function/class signature:
  • def match_drivers_to_riders(drivers: List[Tuple[float, float]], riders: List[Tuple[float, float]]) -> List[Tuple[Tuple[float, float], Tuple[float, float]]]:


Example 1:
  • Input: drivers = [(34.0522, -118.2437), (34.0520, -118.2440)]

  • Riders: [(34.0521, -118.2435), (34.0519, -118.2438)]

  • Output: [((34.0522, -118.2437), (34.0521, -118.2435)), ((34.0520, -118.2440), (34.0519, -118.2438))]

  • Explanation: The first rider is matched with the first driver based on proximity and the second rider with the second driver.


Example 2:
  • Input: drivers = [(34.0522, -118.2437)]

  • Riders: [(34.0521, -118.2435), (34.0519, -118.2438)]

  • Output: [((34.0522, -118.2437), (34.0521, -118.2435))]

  • Explanation: The only available driver serves the first rider, and the second rider remains unmatched.


Constraints:
  • 1 <= len(drivers) <= 100

  • 1 <= len(riders) <= 100

  • Latitude and Longitude values are in the range of [-90, 90] and [-180, 180] respectively.
coding Medium greedy #6

6. LeetCode-style coding challenge — Implement a function to find the optimal ride sharing match

Background: Lyft’s core business involves matching drivers to riders efficiently based on various factors like distance, time, and rider preferences. To enhance the customer experience, it’s crucial to develop an algorithm that can quickly find the best match for both parties.
Problem statement: Given a list of drivers represented as tuples of (id, location) and a list of riders represented as (id, pickup_location), implement a function to return a list of matches. Each match should be a tuple (rider_id, driver_id) such that the distance between the driver and rider is minimized. Assume you have a helper function calculate_distance(location1, location2) that returns the distance between two locations.
Function/class signature:
  • def find_best_matches(drivers: List[Tuple[int, Tuple[float, float]]], riders: List[Tuple[int, Tuple[float, float]]]) -> List[Tuple[int, int]]:

Example 1:
  • Input: drivers = [(1, (0, 0)), (2, (1, 1))]

  • riders = [(1, (0, 1)), (2, (2, 2))]

  • Output: [(1, 1), (2, 2)]

  • Explanation: Driver 1 is closest to rider 1, and driver 2 is closest to rider 2.

Example 2:
  • Input: drivers = [(1, (2, 3))]

  • riders = [(1, (1, 1)), (2, (3, 3))]

  • Output: [(1, 1), (2, 1)]

  • Explanation: Both riders match with driver 1 because there's only one driver available.

Constraints:
  • 1 <= len(drivers) <= 100

  • 1 <= len(riders) <= 100

  • Location coordinates are floating point values, within the range (-10^6, 10^6)
system design Medium api design #7

7. Design DriverRiderMatcher — a service for efficiently matching drivers with riders based on real-time demand and supply conditions.


Background: Lyft aims to enhance user experience by ensuring that riders can be matched quickly to nearby drivers. This service would handle the complexities of demand and supply fluctuations in real-time.
Requirements:
1. The service should allow adding new Driver and Rider instances dynamically as they request a ride or become available.
2. The system must prioritize matching riders with the nearest available driver to minimize wait times.
3. It should support cancellation of ride requests by riders or drivers, updating the available pool appropriately.
4. The service must track ongoing rides and maintain a history of matches for potential analytics.
Class API:
  • add_driver(driver_id: int, location: Tuple[float, float]) -> None: Adds a new driver to the service with a given ID and location.

  • add_rider(rider_id: int, location: Tuple[float, float]) -> None: Registers a new rider with a given ID and location.

  • request_ride(rider_id: int) -> Optional[int]: Matches the rider with the nearest driver, returning the driver's ID or None if no driver is available.

  • cancel_ride(rider_id: int) -> None: Cancels the ride request for the specified rider, freeing up any matched driver.


Example 1:
Input: add_driver(101, (37.7749, -122.4194)) → Output: None
Input: add_rider(201, (37.7750, -122.4192)) → Output: None
Input: request_ride(201) → Output: 101 (implying rider 201 has been matched with driver 101)
Example 2:
Input: add_driver(102, (37.7799, -122.4294)) → Output: None
Input: cancel_ride(201) → Output: None
Constraints:
  • Driver and Rider IDs must be unique integers.

  • Locations are represented as tuples of floating-point latitude and longitude values.

  • The system should handle up to 10,000 drivers and 10,000 riders concurrently.

Start practicing Lyft questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free