解题思路:
(1)两个杯子倒水
class Solution
{
public:
void push(int node) {
while(!s2.empty()) {
s1.push(s2.top());
s2.pop();
}
s1.push(node);
}
int pop() {
while(!s1.empty()) {
s2.push(s1.top());
s1.pop();
}
int temp=s2.top();
s2.pop();
return temp;
}
private:
stack<int> s1;
stack<int> s2;
};