标签:
class Solution { public: bool IsPopOrder(vector<int> pushV,vector<int> popV) { stack<int> s; int len1=pushV.size(); int len2=popV.size(); if(len1!=len2) return false; if(len1==0||len2==0) return false; int i,j; j=0; s.push(pushV[0]); i=1; while(i<=len1){ while(s.top()==popV[j]){ j++; s.pop(); if(j==len2) { break; } } s.push(pushV[i]); i++; } if(j==len2) return true; else return false; } };
标签:
原文地址:http://www.cnblogs.com/cancangood/p/4934346.html