You are viewing a single comment's thread. Return to all comments →
Hi, I have a question about where you check if the top of S is >= than the top of largest_stack: if(S.peek() >= largest_stack.peek()).
Why are you doing largest_stack.push(S.peek()) rather than something like largest_stack.push(newtop) ?
Im sure the answer is fairly obvious but Im a little out of practice when it comes to these things. Thanks!
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, I have a question about where you check if the top of S is >= than the top of largest_stack: if(S.peek() >= largest_stack.peek()).
Why are you doing largest_stack.push(S.peek()) rather than something like largest_stack.push(newtop) ?
Im sure the answer is fairly obvious but Im a little out of practice when it comes to these things. Thanks!