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