Untitled

Anonymous
plain_text
03/31/2025 1:33 PM
544 B
18
Indexable
class Solution:
    def minAddToMakeValid(self, s: str) -> int:
        count_opening=0
        count_closing=0
        for i in s :
            if i =="(" :
                count_opening += 1
            else :
                if count_opening >0 :
                    count_opening -= 1
                else :
                    count_closing += 1
        return count_opening + count_closing
Editor is loading...
Leave a Comment