Problem
Given a collection of intervals, merge all overlapping intervals. For example,
Given
return
[1,3],[2,6],[8,10],[15,18],return
[1,6],[8,10],[15,18].Algorithm
Each interval has a start time and an end time. Sort these intervals by their starting time. Add non overlapping intervals into the result list, and merge the overlapping intervals.
Remember how to write a Comparator class.
Remember how to write a Comparator class.
No comments:
Post a Comment