Glossary: Algorithms Beyond the Basics in Rust
Merging intervals
Also written: merge intervals
Joining overlapping or touching intervals into busy periods: sort by start, then stretch the last period's end when the next interval starts before (or at) it. It costs O(n log n).