How would you implement a stack with the additional operation of getMin?
Anonymous
Jake, It's not that simple. Say you pushed 1, 2, and 3, and then popped 1. If you just keep track of the minimum that was pushed, you would still have 1 but that's not even in the stack anymore. You also can't just erase the value if you pop it off, because then a situation that was like push 1, 1, 2, 3, pop 1 would give you the wrong answer (i.e. should still be 1).
Check out your Company Bowl for anonymous work chats.