Sort intervals by start, then scan and merge. AC