Back to course home
0% completed
Vote For New Content
Using dict in python
Enrique Fernández
Jan 15, 2025
class Solution: def isValid(self, s): # ToDo: Write Your Code Here. stack = [] parentheses = {")": "(" , "]": "[" , "}" : "{"} if len(s) % 2 != 0: return False for c in s: if c not in parentheses.keys(): stack.append(c) elif stack: top = stack.pop(-1) if top != parentheses[c]: return False else: return False return True
0
0
Comments
Comments
On this page