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

栈的压入、弹出序列

https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106

class Solution:
    def IsPopOrder(self , pushV: List[int], popV: List[int]) -> bool:
        # write code here
        ck_stack = []
        n = len(pushV)
        while pushV:
            ck_stack.append(pushV.pop(0))
            while ck_stack and ck_stack[-1] == popV[0]:
                ck_stack.pop()
                popV.pop(0)
        return not popV

全部评论

相关推荐

我只是一个小白菜:我还用不惯m4,也是山猪吃不了细糠了
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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