E
Euroken@euroken
On Merge Intervals, sorting by start time makes everything else a single pass: you only ever compare each interval with the last merged one.
- Did you try to solve it before sorting? What went wrong?
- What other problems have you seen where "sort first, then scan" is the key?
- What is the most surprising input you tested? I would be interested in intervals that only touch at an endpoint, like
[1,3]and[3,5].