Easy Python Solution 7 Line

  • 0
    class Solution(object):
        def eraseOverlapIntervals(self, intervals):
            intervals.sort(key = lambda x: x.start)
            count = 0
            for i in range(len(intervals)-1):
                if intervals[i].end > intervals[i+1].start:
                    intervals[i+1].end = min(intervals[i].end, intervals[i+1].end)
                    count += 1
            return count

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.