Minimum removals required to make ranges non-overlapping


Given a list of ranges with starting and end value, the task is to find the minimum number of ranges that are required to be removed to make remaining ranges non-overlapping.

Examples:

Input : input = {{1, 2}, {4, 7}, {3, 8}}
Output : 1
Explanation: Removal of {3, 8} makes {{1, 2} and {4, 7}} non-overlapping.



Input : input = {{ 10, 20 }, { 10, 20 } , { 10, 20 }}
Output : 2
Explanation: Removal of [10, 20] makes the remaining ranges non-overlapping.

Input : input = {{1, 2}, {5, 10}, {18, 35}, {40, 45}}
Output : 0
Explanation:All ranges are already non-overlapping.

Approach: