class Solution:

    def merge(self, intervals: [[int]]) ->[[int]]:
        if len(intervals) == 0:
            return []
        intervals = sorted(intervals, key=lambda x: (x[0], x[1]))
        result, N = [], len(intervals)
        result.append(intervals[0])
        for i in range(1, N):
            if result[-1][1] >= intervals[i][0]:
                result[-1][1] = intervals[i][1] if intervals[i][1] > result[-1
                    ][1] else result[-1][1]
            else:
                result.append(intervals[i])
        return result

afce2524c6d0392a3fa1d42f6de6fe489dc29f4a
<mask token>

class Solution:
    <mask token>

class Solution:

    def merge(self, intervals: [[int]]) ->[[int]]:
        if len(intervals) == 0:
            return []
        intervals = sorted(intervals, key=lambda x: (x[0], x[1]))
        result, N = [], len(intervals)
        result.append(intervals[0])
        for i in range(1, N):
            if result[-1][1] >= intervals[i][0]:
                result[-1][1] = intervals[i][1] if intervals[i][1] > result[-1
                    ][1] else result[-1][1]
            else:
                result.append(intervals[i])
        return result
