Find the minimum value in the stack in O(1) both time and space complexity.
[]
push(1) : [1]
push(2) : [1,1]
push(3) : [1,1,1]
push(3) : [1,1,1,0]
pop() : 3, [1,1,1]
pop() : 3, [1,1]
pop() : 2, [1]
pop() : 1 [0]
Anyways I had failed to give proper answer and I was rejected in the interview. This was the last question of my last round!
Spoiler: Here is one such solution using a simple but very clever trick: http://www.geeksforgeeks.org/design-a-stack-that-supports-ge...
Is that it?