Question DSA-HEAP-0029
EasyWhat is the output of this code?
import heapq
h = []
for x in [4, 1, 3]:
heapq.heappush(h, x)
print(heapq.heappop(h), heapq.heappop(h))
- A.
4 1
- B.
1 4
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Heaps and Priority Queues question
What is the output of this code?
import heapq
h = []
for x in [4, 1, 3]:
heapq.heappush(h, x)
print(heapq.heappop(h), heapq.heappop(h))
4 1
1 4
Sign up free to see the answer and a step-by-step explanation.
3 1
1 3