Update heapify.py

This commit is contained in:
marina 2023-08-02 13:05:42 -07:00 committed by GitHub
parent 8f4fc49e7a
commit 0588483a19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,3 +16,15 @@ heapq.heapify(min_heap)
max_heap = [-x for x in min_heap] max_heap = [-x for x in min_heap]
heapq.heapify(max_heap) heapq.heapify(max_heap)
heapq.heappush(min_heap, 5)
heapq.heappush(min_heap, -5)
min_elem = min_heap[0]
max_elem = -1 * max_heap[0
heapq.heappop(min_heap)
heapq.heappop(max_heap)
size_min_heap = len(min_heap)
size_max_heap = len(max_heap)