heapq: q --> queue 优先队列,先进先出
import heapq
import random
li = list(range(100))
random.shuffle(li)
print(li)
# 建堆 - 小根堆
heapq.heapify(li)
print(li)
# heappop - 小的先出
for i in range(len(li)):
print(heapq.heappop(li), end=',')
heapq: q --> queue 优先队列,先进先出
import heapq
import random
li = list(range(100))
random.shuffle(li)
print(li)
# 建堆 - 小根堆
heapq.heapify(li)
print(li)
# heappop - 小的先出
for i in range(len(li)):
print(heapq.heappop(li), end=',')