Problem statement

https://binarysearch.com/problems/Movie-Theatres/

Solution

Equal to Leetcode 0253. Meeting Rooms II.

Complexity

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

Code

class Solution:
    def solve(self, ints):
        if not ints: return 0
        points = sorted([(i, 1) for i,_ in ints] + [(j, -1) for _,j in ints])
        return max(accumulate(j for _,j in points))