class Solution {
public:
void push(int value) {
s_data.push(value);
if (s_help.empty() || value < s_help.top()) {
s_help.push(value);
} else {
s_help.push(s_help.top());
}
}
void pop() {
s_data.pop();
s_help.pop();
}
int top() {
return s_data.top();
}
int min() {
return s_help.top();
}
private:
stack<int> s_data;
stack<int> s_help;
};

京公网安备 11010502036488号