#https://leetcode.com/problems/valid-parentheses/

def isValid(s):   
    parents = {')' : '(', '}' : '{', ']' : '['}
    stack = []
    for i in s:
        if i in parents.values():
            stack.append(i)
        else:
            if stack and stack[-1] == parents[i]:
                stack.pop()
            else:
                stack.append(i)
return not stack

6e368ba32ad0e72d6b65f090471988589f196e32
<mask token>

def isValid(s):
    parents = {')': '(', '}': '{', ']': '['}
    stack = []
    for i in s:
        if i in parents.values():
            stack.append(i)
        elif stack and stack[-1] == parents[i]:
            stack.pop()
        else:
            stack.append(i)


<mask token>

def isValid(s):
    parents = {')': '(', '}': '{', ']': '['}
    stack = []
    for i in s:
        if i in parents.values():
            stack.append(i)
        elif stack and stack[-1] == parents[i]:
            stack.pop()
        else:
            stack.append(i)


return not stack

#https://leetcode.com/problems/valid-parentheses/

def isValid(s):   
    parents = {')' : '(', '}' : '{', ']' : '['}
    stack = []
    for i in s:
        if i in parents.values():
            stack.append(i)
        else:
            if stack and stack[-1] == parents[i]:
                stack.pop()
            else:
                stack.append(i)
return not stack
