class Solution {//在这里利用一个辅助栈来解决问题
public:
void push(int value) {
datastack.push(value);
if (minstack.empty()){
minstack.push(value);
}
if (value <= minstack.top()){
minstack.push(value);
}
}
void pop() {
if (datastack.empty()){
return;
}
if (minstack.top() == datastack.top() ){
minstack.pop();
}
datastack.pop();
}
int top() {
return datastack.top();
}
int min() {
return minstack.top();
}
private:
stack<int> datastack;
stack<int> minstack;
};