Non-overlapping Intervals

Intervals and Scheduling DSA practice problem on Onlearn.

Difficulty: medium.

Topics: Non-overlapping Intervals, Greedy Algorithm, Interval Scheduling, Arrays, Sorting, space complexity, greedy algorithm, sorting algorithms, intervals, time complexity analysis.

Problem: Non overlapping Intervals Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non overlapping. Each interval is represented by a pair of integers [start, end], where start < end. Input Specification: An array of intervals where intervals[i] = [starti, endi] Output Specification: Return an integer representing the minimum number of intervals to remove. Constraints: 1 <= intervals.length <= 10^5 intervals[i].length == 2 5 10^4 <= starti < endi <= 5 10^4 Example 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: Removing [1,3] leaves the rest non overlapping. Example 2: Input: [[1,2],[1,2],[1,2]] Output: 2 Explanation: Need to remove two [1,2] intervals. Difficulty: Medium