标签:bsp offer order 剑指offer logs span cto public log
1 class Solution 2 { 3 public: 4 bool IsPopOrder(vector<int> pushV,vector<int> popV) { 5 if(pushV.size() != popV.size()) 6 return false; 7 stack<int> Stack; 8 int i = 0,j = 0; 9 while(i < pushV.size()) 10 { 11 Stack.push(pushV[i ++]); 12 //出栈队列中的元素和栈顶元素相等就出栈 13 while(j < popV.size() && popV[j] == Stack.top()) 14 { 15 Stack.pop(); 16 j ++; 17 } 18 } 19 return Stack.empty();//栈空则返回true 20 } 21 };
标签:bsp offer order 剑指offer logs span cto public log
原文地址:http://www.cnblogs.com/lca1826/p/6480696.html