包含min函数的栈
class Solution {
public:
stack<int> data,assist;
void push(int value) {
data.push(value);
if(assist.empty())
assist.push(value);
else if(value<=assist.top())
assist.push(value);
}
void pop() {
if(data.top()==assist.top())
assist.pop();
data.pop();
}
int top() {
return data.top();
}
int min() {
return assist.top();
}
};