Simple, Clean Python

  • 0
    class Solution(object):
        def merge(self, intervals):
            :type intervals: List[Interval]
            :rtype: List[Interval]
            intervals.sort(key = lambda x: x.start)
            i = 1
            while i < len(intervals):
                if intervals[i].start <= intervals[i-1].end:
                    intervals[i-1].end = max(intervals[i-1].end, intervals[i].end)
                    i += 1
            return intervals

Log in to reply

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