标签:
1 class Solution 2 { 3 public: 4 void push(int node) { 5 stack1.push(node); 6 } 7 8 int pop() { 9 if(stack2.size()<=0){ 10 while(stack1.size()){ 11 int data = stack1.top(); 12 stack1.pop(); 13 stack2.push(data); 14 } 15 } 16 int head = stack2.top(); 17 stack2.pop(); 18 return head; 19 } 20 21 private: 22 stack<int> stack1; 23 stack<int> stack2; 24 };
标签:
原文地址:http://www.cnblogs.com/gaobaoru-articles/p/5236233.html