Really Simple Python Solution


  • 0
    F
        def isValid(self, s):
            stack = []
            for c in list(s):
                if c in ["(", "[", "{"]:
                    stack.append(c)
                else:
                    if len(stack) <= 0 or not stack.pop() + c in ["()", "[]", "{}"]:
                        return False
            return len(stack) == 0

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.