题解 | #栈的压入、弹出序列#
栈的压入、弹出序列
http://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106
# -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pushV, popV): # write code here temp=[] i=0 j=0 while(i<len(pushV)): temp.append(pushV[i]) i+=1 while len(temp)>0 and temp[-1]==popV[j]: temp.pop() j+=1 if len(temp)==0: return True return False