Imagine you're a conference organizer trying to schedule meetings in rooms, but some meetings have overlapping time slots. Your goal is to find the minimum number of meetings to cancel so that no two remaining meetings overlap in time.
Given an array of intervals intervals where intervals[i] = [start_i, end_i], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Important: Intervals that only touch at a single point are considered non-overlapping. For example, [1, 2] and [2, 3] are perfectly fine together!
Example: If you have meetings [[1,2], [2,3], [3,4], [1,3]], you only need to remove 1 meeting (either [1,2] or [1,3]) to make all remaining meetings non-overlapping.
Input & Output
Visualization
Time & Space Complexity
2^n subsets to generate, each taking O(n) time to validate
Space for recursion stack and storing current subset
Constraints
- 1 โค intervals.length โค 105
- intervals[i].length == 2
- -5 ร 104 โค starti < endi โค 5 ร 104
- Important: Intervals touching at endpoints are non-overlapping