Intervals: common mistakes
Merging intervals depends on three small choices: the order, what counts as overlapping, and which end to keep. Here are three slips in Merge Intervals: not sorting by start, keeping touching ranges apart, and taking the next range's end instead of the larger one. Each range has its own lane; merged ranges go in the bottom lane.
Pick a mistake and press play: Wrong runs the code with the mistake until it breaks, and the code marks the wrong line in red. Fixed runs the corrected code on the same input, with the corrected line in green.