+ 1

Queues

How can I get the max element of a queue and how can I print it? Shoul I include it in pop function or I have to make another function for it?

24th Mar 2018, 3:55 PM
Winter Soldier
Winter Soldier - avatar
2 Réponses
+ 1
If you are able, you could keep information about your queue as you fill it. I would personally use a class for this. You could also find it the way you mentioned it - with pop(), but you will have to pop every element to find which one is the max.
24th Mar 2018, 5:32 PM
Zeke Williams
Zeke Williams - avatar
0
https://hastebin.com/qazenuqera.cpp here's my code, but not sure if it's right
24th Mar 2018, 5:43 PM
Winter Soldier
Winter Soldier - avatar