DEV Community

Discussion on: Finding Max in a Stack

Collapse
 
sduduzog profile image
Sdu

No no, I do understand your solution fully. What I didn't make clear though is that my solution assumes that a stack is already hydrated when it gets the max value, and your solution is perfect for getting the max value without traversing the stack each time max is required. I'm not sure if you get me

Thread Thread
 
racheladaw profile image
Rachel Williams

Oh I see. I did misunderstand at first, I apologize for that. So your solution is a loop, but with pushing to a holding stack while comparing values? This also assumes that no new values are added to the stack. Am I understanding it correctly?

Thread Thread
 
sduduzog profile image
Sdu

Yes that definitely it