//No more easier than it.
class Solution
{
public:
void push(int node) {
stack1.push(node);
}
int pop() {
while(!stack1.empty()){
int cur = stack1.top();
stack2.push(cur);
stack1.pop();
}
int ans = stack2.top();
stack2.pop();
while(!stack2.empty()){
int cur = stack2.top();
stack1.push(cur);
stack2.pop();
}
return ans;
}
private:
stack<int> stack1;
stack<int> stack2;
};

京公网安备 11010502036488号