标签:列表 public space 处理 解题思路 == als offer white
1 class Solution { 2 public: 3 //借助辅助栈实现 4 bool IsPopOrder(vector<int> pushV,vector<int> popV) { 5 bool result = false; 6 int length1 = pushV.size(); 7 int length2 = popV.size(); 8 if(!pushV.empty() && !popV.empty() && length1 == length2) 9 { 10 stack<int> tmp; 11 int j = 0; 12 for(int i=0;i<length1;i++) 13 { 14 tmp.push(pushV[i]); 15 while((!tmp.empty())&&(tmp.top() == popV[j])) 16 { 17 tmp.pop(); 18 j++; 19 if(j == length2) 20 { 21 result = true; 22 break; 23 } 24 } 25 } 26 27 } 28 return result; 29 } 30 };
标签:列表 public space 处理 解题思路 == als offer white
原文地址:http://www.cnblogs.com/qqky/p/6894172.html