35/42
Part 8 of 8 · Follow-upsLearn and do

The most pay from jobs that can't overlap: sort by end, then take or skip each job

That's the worked example of the sorting and binary search lesson. Sort by end. For each job, take the better of two choices: skip it, or take it plus the best before its start, found with bisect_right.

It's on Airbnb's LeetCode tag lists (4 sources), and one Airbnb software engineer candidate reports it as a phone screen (1 report). Its tie rule is the half-open one: a job can start the hour another ends.

In the editor, each job is (start, end, pay). max_pay(jobs) sorts them by end, and best[j] is the most pay from the first j jobs. Write the loop body: skip the job, or take it plus the best before its start.