Sunday, January 19, 2014

Merge Intervals (Java)

LeetCode


Given a collection of intervals, merge all overlapping intervals.
For example,
Given [1,3],[2,6],[8,10],[15,18],
return [1,6],[8,10],[15,18].

Solution:
Sort the list base on start valuable in an interval, then a while loop merge every overlap interval.