2406. Divide Intervals Into Minimum Number of Groups

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2406

class Solution:
    def minGroups(self, intervals: List[List[int]]) -> int:
        h = []
        for a, b in sorted(intervals):
            if h and h[0] < a:
                heappop(h)
            heappush(h, b)
        return len(h)