2406. Divide Intervals Into Minimum Number of Groups

Обновлено: 2024-03-12
1 мин
[]

Содержание

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)