@@ -0,0 +1,1157 @@
+import unittest%0A%0A%0A# Definition for an interval.%0Aclass Interval(object):%0A    def __init__(self, s=0, e=0):%0A        self.start = s%0A        self.end = e%0A%0A%0Aclass Solution(object):%0A    def eraseOverlapIntervals(self, intervals):%0A        %22%22%22%0A        :type intervals: List%5BInterval%5D%0A        :rtype: int%0A        %22%22%22%0A        if not intervals:%0A            return 0%0A%0A        intervals.sort(key=lambda x: x.start)%0A        prev = intervals%5B0%5D%0A        result = 0%0A%0A        for curr in intervals:%0A            if curr.start %3C prev.end:%0A                result += 1%0A                if curr.end %3C= prev.end:%0A                    prev = curr%0A            else:%0A                prev = curr%0A%0A        return result - 1%0A%0A%0Aclass Test(unittest.TestCase):%0A    def test(self):%0A        self._test(%5B%5B1, 2%5D, %5B2, 3%5D, %5B3, 4%5D, %5B1, 3%5D%5D, 1)%0A        self._test(%5B%5B1, 2%5D, %5B1, 2%5D, %5B1, 2%5D%5D, 2)%0A        self._test(%5B%5B1, 2%5D, %5B2, 3%5D%5D, 0)%0A%0A    def _test(self, intervals, expected):%0A        intervals = %5BInterval(start, end) for start, end in intervals%5D%0A        actual = Solution().eraseOverlapIntervals(intervals)%0A        self.assertEqual(actual, expected)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

435. Non-overlapping Intervals. O(nlog(n))