Remove Covered Intervals🚲

Input: intervals = [[1,4],[3,6],[2,8]]
Output: 2
Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
Input: intervals = [[1,4],[2,3]]
Output: 1
  • 1 <= intervals.length <= 1000
  • intervals[i].length == 2
  • 0 <= li < ri <= 105
  • All the given intervals are unique.

Java Solution

Two different solutions with two different time complexities, but the second solution will have two different versions both using the same algorithm but the one is using the sort function provided by the language and the other one is using merge sort which is written in the code.

Code

Code

Version 1

Version 2

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store