Yodlee Interview Question

Find the max element in a stack at any given point of time

Interview Answer

Anonymous

Jan 21, 2018

I wrote a function which used a temp stack, while popping the element out from the given stack I was checking the max value and pushing the value in temp stack,at last I have max element and to maintain the stacks order I pushed back the elements from the temp stack to the given stack