You are viewing a single comment's thread. Return to all comments →
Hi Puneet,
I tried your code, it worked. Then I made a minor change, that is
if(S.peek()>=largest_stack.peek()){ largest_stack.push(S.peek()); }
to
if(S.peek()>=largest_stack.peek()){ largest_stack.push(newtop); }
Upon doing so, cases 8-16 failed. Can you (or anyone else reading this) tell me why this is happening?
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Hi Puneet,
I tried your code, it worked. Then I made a minor change, that is
to
Upon doing so, cases 8-16 failed. Can you (or anyone else reading this) tell me why this is happening?