All problems
0093HardArrayBinary SearchDynamic ProgrammingSorting

Studio Booking Payout

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1235Maximum Profit in Job Scheduling

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A recording studio has a stack of booking requests to answer. Request i wants the room from hour start[i] until hour finish[i] and pays payout[i] if it is accepted.

The room holds one session at a time, so two accepted requests may not overlap. Requests that merely touch are fine: a request that ends at hour t can be followed by one that begins at hour t, because the engineer resets the room instantly.

Accept any collection of requests you like, subject to that rule, and return the largest total payout obtainable. Accepting nothing is allowed but never necessary, since every payout is positive.

Examples

Example 1

Input
start = [1, 3], finish = [3, 5], payout = [6, 6]
Output
12

The second request begins on the hour the first one ends, so both fit and the studio collects everything.

Example 2

Input
start = [1, 1, 3], finish = [10, 3, 6], payout = [20, 12, 12]
Output
24

Two shorter back-to-back sessions beat the single long one that pays 20 and blocks the whole day.

Example 3

Input
start = [1, 2, 3], finish = [8, 7, 9], payout = [5, 9, 3]
Output
9

Every pair of requests overlaps here, so only the best paying one can be taken.

Constraints

  • 1 <= start.length == finish.length == payout.length <= 5 * 10^4
  • 1 <= start[i] < finish[i] <= 10^9
  • 1 <= payout[i] <= 10^4

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def max_payout(start: list[int], finish: list[int], payout: list[int]) -> int:
Java
public int maxPayout(int[] start, int[] finish, int[] payout)
September 7
Apply