':type intervals: List[Interval]
:rtype: int'

def eraseOverlapIntervals(self, intervals):

    intervals.sort(key=(lambda interval: interval.start))
    (result, prev) = (0, 0)
    for i in xrange(1, len(intervals)):
        if (intervals[i].start < intervals[prev].end):
            if (intervals[i].end < intervals[prev].end):
                prev = i
            result += 1
        else:
            prev = i
    return result
