← 返回题库
中级

栈的压入、弹出序列

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    pushed = list(map(int, pushed.split(____)))
    popped = list(map(int, popped.split(____)))
    stack = []
    i = ____
    for num in pushed:
        stack.append(____)
        while stack and i < len(____) and stack[-____] == popped[i]:
            stack.pop()
            i += ____
    print('____' if i == len(____) else '____')

示例

输入
1,2,3,4,5|4,5,3,2,1
期望输出
true
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码