Implement a stack with push, pop, top, and getMin. getMin should return the smallest value currently in the stack.
The minimum must reflect the current stack after previous pushes and pops. A value that was popped should no longer influence getMin.
Examples
Input: operations = ["MinStack","push","push","push","getMin","pop","top","getMin"], values = [null,-2,0,-3,null,null,null,null] Output: [null,null,null,null,-3,null,0,-2]
Input: operations = ["MinStack","push","push","top","getMin","pop","getMin"], values = [null,2,1,null,null,null,null] Output: [null,null,null,1,1,null,2]
Constraints
- 1 <= operations.length <= 20,000
- operations[i] is one of MinStack, push, pop, top, or getMin.
- values[i] is null unless operations[i] is push.