题解 | #栈的压入、弹出序列#

栈的压入、弹出序列

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
全部评论

相关推荐

11-06 16:50
门头沟学院 Java
用微笑面对困难:word打字比赛二等奖的我,也要来凑合凑合
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务