Min Stack
Medium๐ท๏ธ Stacks & queues๐ Stacks & Queues
๐งฉ The problem
Design a stack that supports push(x), pop(), top() and getMin() โ all in O(1). The tests run a list of commands and print the results of top and getMin.
Examples
push 5, push 3, getMin โ 3, pop, getMin โ 5
๐ฏ Aim for: O(1) per operation
โ๏ธ Write your solution
Pick a language, press Run to try it, then Run tests to check it against every test case โ just like a coding interview.