87. Stack With Constant-Time Minimum
MediumStacks
Simulate a stack that supports push, pop, top and getMin, each in O(1) time. You receive two arrays of equal length: ops (operation names) and values (values[i] is the number to push when ops[i] is "push", otherwise null).
Return an array with one entry per operation: null for "push" and "pop", the top value for "top", and the smallest value currently on the stack for "getMin".
"pop", "top" and "getMin" are never called on an empty stack.
Example 1
Input: ops = ["push","push","push","getMin","pop","top","getMin"], values = [-2, 0, -3, null, null, null, null] Output: [null, null, null, -3, null, 0, -2]
Constraints
1 ≤ ops.length ≤ 10⁴