More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
when you an element to the stack check these two condition
1. Stack is empty, then MAX = element
2. Stack is not empty then check if the element is greater than MAX then MAX = element
when getMax fuction is called, then return MAX
Help us improve. Please let us know the company, where you were asked this question :