Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
 sealess
Stack Python

sealess

Aug 13, 2024

class Solution: def minAddToMakeValid(self, S: str) -> int: # ToDO: Write Your Code Here. stack = [] for i in S: if not stack or i=='(': stack.append(i) elif i == ')' and stack: if stack[-1] != '(': stack.append(i) else: stack.pop() print(stack) return len(stack)

0

0

Comments
Comments

On this page