问题描述
解题思路
实现源码
class Solution
{
public:
void push(int node) {
stack1.push(node);
}
int pop() {
if(stack1.empty() == true)
return NULL;
while(stack1.empty() == false) {
int temp1 = stack1.top();
stack2.push(temp1);
stack1.pop();
}
int result = stack2.top();
stack2.pop();
while(stack2.empty() == false) {
int temp2 = stack2.top();
stack1.push(temp2);
stack2.pop();
}
return result;
}
private:
stack<int> stack1;
stack<int> stack2;
};