5 条题解

  • 1
    @ 2023-11-7 9:52:31

    【栈】表达式括号匹配(stack){\large\color{#92a1e8}【栈】表达式括号匹配(stack)}

    一个基础的栈

    难度:入门\texttt{\color{#e51211}难度:入门} easy\textit{\small\color{#e51211}easy}

    last update:2023/11/7

    更多帮助


    Python{\large\color{#52a1e8}Python:}

    st=[""]*100
    top=0
    s=input()
    flag=True
    for i in range(len(s)):
        if s[i]=='(':
            top+=1
        if s[i]==')':
            top-=1
        if(top<0):
            flag=False
            break
    if(flag==True and top==0):
        print("YES")
    else:
        print("NO")
    

    信息

    ID
    275
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    1066
    已通过
    250
    上传者