题解 | #有效括号序列#

有效括号序列

https://www.nowcoder.com/practice/37548e94a270412c8b9fb85643c8ccc2

class Solution:
    def isValid(self , sstr) -> bool:
        # write code here
        dic={'(':')','[':']','{':'}'}
        list1=[]
        for i in s:
            if i in '({[':
                list1.append(dic[i])
            elif len(list1)==0:
                return False
            elif list1[-1]==i:
                list1.pop()
        return len(list1)==0

全部评论

相关推荐

Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
06-02 15:17
门头沟学院 Java
心爱的idea:怎么会呢 应该是打招呼有问题 问就说实习6个月全国可飞随时到岗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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