Trains the technique from
LeetCode 435Non-overlapping IntervalsThis 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 ceramics studio books firings on one shared kiln. Every request comes in as a pair [start, finish] inside runs, both measured in minutes from the studio's reference mark; a request that sits earlier than the mark uses negative minutes, and a firing always finishes after it starts.
Two requests clash when the stretches of kiln time they occupy share at least one minute. A firing that finishes on the exact minute another begins does not clash with it, since the kiln is free again at that mark.
Cancel as few requests as possible so that no two survivors clash. Return how many requests you had to cancel.
Example 1
Cancelling the request that runs from 2 to 6 leaves the other two, which share no minute. Keeping all three is impossible because the middle firing clashes with both of the others.
Example 2
Each firing finishes exactly when the next one begins, so the kiln is never double booked and nothing has to go.
Example 3
Dropping the short middle request keeps the two long firings, which never overlap. Cancelling one of the long firings instead would leave the remaining pair still clashing.
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 min_runs_to_cancel(runs: list[list[int]]) -> int:public int minRunsToCancel(int[][] runs)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.