Return the minimum number of intervals you need to remove to make the rest non-overlapping.
Input: intervals = [[1,2],[2,3],[3,4],[1,3]]
Output: 1
Topics: greedy, sorting
Asked by: Meta, Amazon
Time complexity: O(n log n). Space complexity: O(1).