Python
class Solution(object):
def isPopOrder(self, pushV, popV):
if len(pushV) != len(popV):
return False
stack = []
while pushV:
stack.append(pushV.pop(0))
while stack and stack[-1] == popV[0]: #stack
stack.pop()
popV.pop(0)
if stack:
return False
else:
return True