#getting a void return from priorityqueue
22 messages · Page 1 of 1 (latest)
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.
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
is this std::priority_queue ?
Yes
priority_queue<int> maxHeap;
long long total = 0;
for(int i = 0; i < nums.size();++i){
maxHeap.push(nums[i]);
}```
pop returns void and removes the largest element, use top to access the lartest element
iirc pop always returns nothing in c++ for any data structure that implements it
Yeah
in python, heapq retursn when popped
so I was used to it
I'll just close this thread thanks y'all ❤️
@eternal coral Has your question been resolved? If so, run !solved :)
!solved