3975. Filter Occupied Intervals
You are given a 2D integer array
occupiedIntervals, whereoccupiedIntervals[i] = [start_i, end_i]represents a time interval during which you are occupied. Each interval starts atstart_iand ends atend_i, inclusive. These intervals may overlap.You are also given two integers
freeStartandfreeEnd, which define a free time interval fromfreeStarttofreeEnd, inclusive.Your task is to merge all occupied intervals that overlap or touch, then remove all integer points in the free interval from the merged occupied intervals.
Two intervals touch if the second interval starts immediately after the first one ends. For example,
[1, 1]and[2, 2]touch and should be merged into[1, 2].Return the remaining occupied intervals in sorted order. The returned intervals must be non-overlapping and must contain the minimum number of intervals possible. If there are no remaining occupied points, return an empty list.
1 | class Solution { |