#getting a void return from priorityqueue

22 messages · Page 1 of 1 (latest)

eternal coral
#
            
            int top = maxHeap.pop();
            total+=top;
            top = ceil(top / 3.0);
            if(top){
                maxHeap.push(top);
            }
            k--;
        }```
umbral sequoiaBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

eternal coral
#

Can anyone tell me why the int top = maxHeap.pop() is giving returning a void return if I am alr checking if maxHeap is empty or not

eternal coral
#

Yes

#
        priority_queue<int> maxHeap;
        long long total = 0;
        for(int i = 0; i < nums.size();++i){
            maxHeap.push(nums[i]);
        }```
fading trench
# eternal coral Yes

pop returns void and removes the largest element, use top to access the lartest element

eternal coral
#

Oh

#

💀

#

I thot pop returned

#

thank you very much @fading trench

#

❤️

eternal coral
#

thank you again

#

it works

uncut pulsar
eternal coral
#

Yeah

#

in python, heapq retursn when popped

#

so I was used to it

#

I'll just close this thread thanks y'all ❤️

umbral sequoiaBOT
#

@eternal coral Has your question been resolved? If so, run !solved :)

eternal coral
#

!solved