Trains the technique from
LeetCode 1229Meeting SchedulerThis 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.
Two people's free periods are given as slots1 and slots2, each entry a pair [start, end] meaning free from start up to end. A person's own periods never overlap each other.
Find the earliest moment t at which both are free for a stretch of duration, that is where the whole of t to t + duration lies inside one period of each.
Return [t, t + duration], or an empty list when no such moment exists.
Example 1
The first overlap runs from 20 to 27, only seven long. The next runs from 50 to 55, five long. The one from 80 to 90 is ten long, so the stretch starts at 80.
Example 2
The two periods meet at a single moment and overlap over nothing, so there is no room even for a stretch of one.
Example 3
The periods are not given in order, and sorting them first shows the earliest workable overlap starts at 0.
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_available_duration(slots1: list[list[int]], slots2: list[list[int]], duration: int) -> list[int]:public List<Integer> minAvailableDuration(int[][] slots1, int[][] slots2, int duration)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.