Question DSA-HEAP-0041
MediumWhat is the output of this code?
import heapq
h = []
for x in [5, 3, 8, 1, 9, 2]:
heapq.heappush(h, x)
print(h[0], [heapq.heappop(h) for _ in range(3)])
- A.
1 [1, 3, 5]
- B.
1 [9, 8, 5]
- C.
Sign up free to see the answer and a step-by-step explanation.