435. Non overlapping Intervals (Medium) - TengnanYao/daily_leetcode GitHub Wiki

class Solution(object):
    def eraseOverlapIntervals(self, intervals):
        """
        :type intervals: List[List[int]]
        :rtype: int
        """
        end = float("-inf")
        count = 0
        intervals.sort(key = lambda x: x[1])
        for interval in intervals:
            if interval[0] >= end:
                end = interval[1]
            else:
                count += 1
        return count