Push Pop Or Replace
import heapq
h = [3, 5, 8]
a = heapq.heappushpop(h, 1)
b = heapq.heapreplace(h, 2)
print(a, b, h)
What does this print?
Sign in to answer questions and track your progress
Sign Inimport heapq
h = [3, 5, 8]
a = heapq.heappushpop(h, 1)
b = heapq.heapreplace(h, 2)
print(a, b, h)
What does this print?
Sign in to answer questions and track your progress
Sign In