D
D
dstdfx2015-11-27 01:48:12
Python
dstdfx, 2015-11-27 01:48:12

Method that returns the maximum element in the queue (heapq)?

Good day. Actually, there was a need for a similar method (heappop ()) for the queue using heapq, only we return the maximum element. Maybe someone faced a similar problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
angru, 2015-11-27
@angru

original solution

A
alpy, 2015-11-28
@alpy

If you just want to return the maximum element without deleting, then
if you also delete it, then nothing, because this contradicts the very structure of the prioritized queue.
If you need to have a reverse order of prioritization, then create wrappers that invert elements when inserting and deleting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question