Most profitable delivery jobs
A free hard coding practice problem. Solve it in JavaScript, TypeScript or Python and check your solution against fresh hidden tests — edge cases and random inputs — as often as you like.
- Difficulty
- Hard
- Type
- Function
- Languages
- JavaScript, TypeScript or Python
Problem
A courier can take one delivery job at a time. jobs is a list of [start, end, pay] (integers, start < end, pay ≥ 1); a job occupies [start, end), so a job may begin exactly when another ends. Return the largest total pay from a set of jobs that don't overlap. Up to 60,000 jobs.
Function signature
// JavaScript
function maxEarnings(jobs)
// TypeScript
function maxEarnings(jobs: any): any
// Python
def max_earnings(jobs):Examples
maxEarnings([[1,3,50],[2,4,10],[3,5,40],[3,6,70]])→120maxEarnings([[1,2,5],[1,3,9],[2,4,6],[3,5,4]])→13
How checking works
Run your code against the examples above, then submit a check: it runs on the server against hidden tests built fresh each time, including edge cases and random inputs. Practice is untimed and never affects a verified score; when you are ready, take a graded coding challenge to earn a badge.