Trains the technique from
LeetCode 1751Maximum Number of Events That Can Be Attended IIThis 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 hall has bookings on offer. bookings[i] = [first, last, fee] runs from day first to day last, both days included, and pays fee.
Take at most k of them, and no two taken bookings may share a day.
Return the largest total fee that can be earned.
Example 1
The two bookings share day 2, so only one may be taken and the larger fee wins.
Example 2
The long booking pays 5 on its own, while the two short ones share no day and pay 4 each.
Example 3
The four bookings share no days at all, but only two of them may be taken.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_value(bookings: list[list[int]], k: int) -> int:public int maxValue(int[][] bookings, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.