请你设计一个 最小栈 。它提供 pushpoptop 操作,并能在常数时间内检索到最小元素的栈。

 

实现 MinStack 类:

 

示例 1:

输入:
["MinStack","push","push","push","getMin","pop","top","getMin"]
[[],[-2],[2],[-3],[],[],[],[]]

输出:
[null,null,null,null,-3,null,2,-2]

解释:
MinStack minStack = new MinStack();
minStack.push(-2);
minStack.push(2);
minStack.push(-3);
minStack.getMin();   --> 返回 -3.
minStack.pop();
minStack.top();      --> 返回 2.
minStack.getMin();   --> 返回 -2.

 

 
提示:

 

注意:本题与主站 155 题相同:https://leetcode-cn.com/problems/min-stack/