PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates spatial algorithms and real-time optimization for ride dispatch together with interval scheduling and capacity planning competencies, covering skills in computational geometry, routing, demand forecasting, and temporal overlap reasoning.

  • Medium
  • Lyft
  • Coding & Algorithms
  • Data Scientist

Optimize Driver Repositioning for Minimal Pickup Time

Company: Lyft

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

##### Scenario Design and implement algorithms for ride-sharing dispatch and capacity planning. ##### Question Given historical rider demand density and current driver GPS locations, design an algorithm to reposition drivers in real time to minimize expected pickup time across the city. Given N ride requests defined by start and end timestamps, return the minimum number of drivers required so all rides are served without overlap. ##### Hints Discuss greedy vs. optimization approaches, spatial indexing (k-d tree, grid), and complexity; for the second problem think sweep-line or min-heap.

Quick Answer: This question evaluates spatial algorithms and real-time optimization for ride dispatch together with interval scheduling and capacity planning competencies, covering skills in computational geometry, routing, demand forecasting, and temporal overlap reasoning.

You are given N ride requests as a list of intervals requests, where each request is [start, end] with integer times. A driver can serve at most one ride at a time. Rides use half-open intervals [start, end), so a ride starting at time t does not overlap with a ride ending at time t. Return the minimum number of drivers required so that all rides can be served without overlap.

Constraints

  • 0 <= N <= 200000
  • requests[i] = [start, end] with integers
  • 0 <= start < end <= 10^9
  • Intervals are half-open: [start, end)
  • Return an integer representing the minimum number of drivers

Hints

  1. Model the problem as finding the maximum number of overlapping intervals.
  2. Sort rides by start time and use a min-heap of end times to reuse drivers whose rides have finished.
  3. When the earliest end time is <= current start, pop it and reuse that driver.
  4. Alternatively, sort start and end arrays separately and sweep with two pointers.
  5. Half-open intervals mean end == start does not count as overlap.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Smallest Covering Window in a String - Lyft (medium)
  • Implement Grid Spread and Transactional Store - Lyft (hard)
  • Assign Minimum Workers to Jobs - Lyft (medium)
  • Solve substring and worker assignment - Lyft (medium)
  • Implement Cache and Key-Value Store - Lyft (medium)