The solution is simpler than mine.
For res[-1][1] = max(res[-1][1], interval[1]), we only need to update the right edge, because the interval[0] is always > res[-1][0]. Cool!
Since we are dealing with intervals that are already sorted based on start value. This overlap check should be enough:
def overlap(a, b):
return not (a[1] < b[0])
why space complexity is O(1)? We need to allocate extra memory for res
array in order to keep overlapped intervals.