Problem statement

https://binarysearch.com/problems/Interval-Intersection/

Solution

Find max of the left ends and min of the right ends.

Complexity

It is O(n) for time and O(1) for space.

Code

class Solution:
    def solve(self, I):
        l = max(x for x, y in I)
        r = min(y for x, y in I)
        return [l, r]