Design a stack that supports push(x), pop(), top(), and retrieving the minimum element in constant time. Implement the MinStack class.
nums = elements of stack (last element is top)
minimum element in the stack
Example 1:
Input:
nums = [3,1,4,2]
Output:
1
Explanation:
The minimum element is 1.
Example 2:
Input:
nums = [5,5,5]
Output:
5
Explanation:
All elements are equal; min is 5.