<filename>921-Minimum_Add_to_Make_Parentheses_Valid.py<gh_stars>1-10
class Solution:
    def minAddToMakeValid(self, s: str) -> int:
        
        if not s: return 0
        
        queue = 0
        move = 0
        for char in s:
            if char == "(":
                queue += 1
            else:
                if queue < 1:
                    move += 1
                else:
                    queue -= 1
        
        return move + queue

<filename>921-Minimum_Add_to_Make_Parentheses_Valid.py<gh_stars>1-10
class Solution:
    def minAddToMakeValid(self, s: str) -> int:
        
        if not s: return 0
        
        queue = 0
        move = 0
        for char in s:
            if char == "(":
                queue += 1
            else:
                if queue < 1:
                    move += 1
                else:
                    queue -= 1
        
        return move + queue
