4 ms·
Yes thats right, you can come up with any solution. But make sure O(1) is satisfied (both in time and space complexity). Anyways I had failed to give proper an
by antoaravinth 10y ago
Yes thats right, you can come up with any solution. But make sure O(1) is satisfied (both in time and space complexity).
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-getmin-in-o1-time-and-o1-extra-space/ http://www.geeksforgeeks.org/design-a-stack-that-supports-ge...