Maximize Driver Earnings From Non-Overlapping Scheduled Trip Offers

Last updated: November 29, 2026

Quick Overview

A driver sees scheduled trip offers, each with a start time, end time and payout; accepting trips that overlap is not allowed. Return the maximum total payout the driver can earn.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


A driver sees scheduled trip offers, each with a start time, end time and payout; accepting trips that overlap is not allowed. Return the maximum total payout the driver can earn.

Uber Reserve and Freight load boards present drivers with many offers, and recommending the best non-conflicting set is a classic optimization. The onsite interviewer expects weighted interval scheduling: sort by end, binary search the last compatible trip, and a 1D DP.

What the Interviewer Expects
  • Explain why the earliest-end greedy fails with payouts
  • Sort trips by end time
  • Define dp[i] as the best payout using the first i trips
  • Use binary search to find the last trip ending before trip i starts
  • Reconstruct the chosen trips if asked
Key Topics to Cover
dynamic programming
weighted interval scheduling
binary search
sorting
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return the chosen trips, not only the total
  • What if the driver needs 10 minutes of buffer between trips?
  • What if the driver can do at most K trips?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of (start, end, payout) with half-open [start, end) intervals, so a trip ending at 10 is compatible with one starting at 10.
  • Output: maximum total payout from a non-overlapping sub...
High-Level Design

Greedy by earliest end maximizes the number of trips, not payout: one long airport run may beat three short trips. Sort trips by end time. Let dp[i] be the best payout using only the first i trips...


Submit Your Answer
Markdown supported