https://leetcode.com/problems/valid-parentheses/
class Solution:
def isValid(self, s: str) -> bool:
st = []
for e in s:
if e in ['(','[','{']:
st.append(e)
elif st and ((st[-1] == '(' and e == ')') or (st[-1] == '[' and e == ']') or (st[-1] == '{' and e == '}')):
st.pop()
else:
return False
return len(st) == 0