def count_heap(self, intervals):
        """
        Heap

        :param intervals: a list of Interval
        :return: an integer
        """
        import heapq

        intervals.sort(cmp=Solution.cmp)
        heap = []
        cnt = 0
        for intv in intervals:
            # in, with upper boundary
            heapq.heappush(heap, intv.end)
            # out, by comparing lower boundary
            while heap[0] <= intv.start:
                heapq.heappop(heap)

            cnt = max(cnt, len(heap))

        return cnt
dataset/ETHPy150Open algorhythms/LintCode/Number of Airplanes in the Sky.py/Solution.count_heap/original