标签:
1 class Solution { 2 public: 3 bool IsPopOrder(vector<int> pushV,vector<int> popV) { 4 5 if(pushV.empty()||popV.empty()||pushV.size()!=popV.size()) 6 return false; 7 8 stack<int> s; 9 int j=0; 10 11 for(int i=0;i<pushV.size();i++) 12 { 13 s.push(pushV[i]); 14 while(!s.empty()&&s.top()==popV[j]) 15 { 16 s.pop(); 17 j++; 18 } 19 } 20 21 if(s.empty()) 22 return true; 23 else 24 return false; 25 } 26 };
标签:
原文地址:http://www.cnblogs.com/SeekHit/p/5775309.html