Generation

generate functionSat, 12 Nov 2022

create a maximum priority queue

def maxheap(iterable): heap = [] for value in iterable: heappush(heap, -value) return [-heappop(heap) for i in range(len(heap))]

Questions about programming?Chat with your personal AI assistant