intervals
by their end times in ascending order.count
to 0 to keep track of the number of intervals to remove.end
to the smallest possible integer value to represent the end time of the last added interval.end
, update end
to the current interval's end time.
b. If the current interval's start time is less than end
, increment count
as this interval overlaps and needs to be removed.count
as the minimum number of intervals to remove.