``` add o(log n) remove min O(log n) find min O(1) - min heap
from heapq import *
heap = []
heappush(heap, 1) heappush(heap, 2) heappush(heap, 3)
heap[0] # 1
heappop(heap) # 1
len(heap) # 2
nums = [43, 2, 13, 634, 120] heapify(nums) -> O(n)
binary tree where parent node is always smaller than child node. can access heap[0] without pop max heap can be made with negative values. but be careful when using the value.
don’t forget heap building time complexity heap[1] is not second smallest!
heapq.heappush(heap, (val, key)) sorted_arr = sorted(arr, key = lambda num: abs(x - num))