import heapq

def min_classrooms(classes):
    classes.sort()

    heap = []

    for start, end in classes:
        if heap and heap[0] <= start:
            heapq.heappop(heap)

        heapq.heappush(heap, end)

    return len(heap)


classes = [(0, 30), (5, 10), (15, 20)]
print(min_classrooms(classes))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: