You know the merge algorithm in code. Now run it with your hands.
Sorted intervals arrive on a number line one by one. For each arrival, you have one decision: does this interval overlap the last committed bar, or does it start a new group?
No code editor. No multiple choice. Just a number line and your spatial intuition.
Four sorted intervals from the classic LC56 example. Process each arrival — tap Merge or New.
If you run the merge-intervals pass on this list, how many distinct groups will remain at the end?
Now the intervals arrive unsorted. Sort them by tapping in the right order, then merge overlapping bars by dragging them together.
Which field do we sort intervals by before merging?
[1,10] fully contains [2,3] and [4,8]. When you drag the contained interval toward the committed bar, watch what happens to the end boundary.
Math.max(10, 3) = 10 — the interval does not shrink.
A new interval has arrived. What should happen with it?
or tap the dashed bar to merge it into the last group