5 Lines Python


  • 0
    class Solution(object):
        def eraseOverlapIntervals(self, intervals):
            intervals.sort(key = lambda x: x.start)
            ans, farest = 0, -0xffffffff
            for interval in intervals:
                farest, ans = min(farest, interval.end) if interval.start < farest else interval.end, ans + 1 if interval.start < farest else ans
            return ans
    

Log in to reply
 

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