Trains the technique from
LeetCode 2140Solving Questions With BrainpowerThis 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 shift offers tasks in a fixed order, given as tasks, where tasks[i] = [points, rest].
Work through the tasks from the first to the last. At each task you may either take it, earning its points and then skipping the next rest tasks entirely, or leave it and move straight on to the next.
Return the most points the shift can earn.
Example 1
Leaving the first task and taking the second earns nine, which beats taking the first for one and then being skipped past everything else.
Example 2
Each task skips the one after it, so the first and the third can both be taken, earning ten.
Example 3
One task, so take it: the rest period runs off the end of the shift and costs nothing.
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 most_points(tasks: list[list[int]]) -> int:public long mostPoints(int[][] tasks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.