Super simple approach, beats 100%, O(1) space and O(n) time, YouTube Video added
Youtube Solution https://youtu.be/UojbHmdbj7Q\n# Intuition and approach\n  keep it very very simple guys , just like below :- \n  i have variable open = 0, mism
# Youtube Solution https://youtu.be/UojbHmdbj7Q\n# Intuition and approach\n  keep it very very simple guys , just like below :- \n  i have variable **open = 0, mismatch = 0**\n  now traverse in the string \nif **char = \'(\'** ==> open++;\nelse ===> **if(open>0)==> open--** ; (because we have to decrease open count as we found pairing close bracket)\n but **if(open==0)** that means we are finding closing bracket without having an open bracket ===> like below case\n**)()()** ===> we have a **leading close bracket** and no open one\n\nso we will increase **mismatch++**\n\nfinally we will return **(mismatch + open)** as answer.\n**now you might have question, how can i return as sum of both variable**\n\njust observe this string **)()()(((** ==> **mismatch = 1**\n                                      ==> **open = 3** (total orphan open brackets)\n\nans = mismatch + open = 1 + 3 = 4\n\nwe need to add 4 operation ==> **(**)()()(((**)))** \n\n**still have doubt, will release Youtube video soon**\n\n\n \n\n\n# Code\n```java []\nclass Solution {\n    public int minAddToMakeValid(String s) {\n    int open =0, mismatch=0;\n    for(int i=0; i<s.length(); i++)\n    {\n     if(s.charAt(i)==\'(\')\n     open++;\n     else\n     {\n        if(open>0)\n        open--;\n        else\n        mismatch++;\n     }\n    } \n     return open+mismatch;   \n    }\n}\n```C++\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        int open = 0, mismatch = 0;\n        for (int i = 0; i < s.length(); i++) {\n            if (s[i] == \'(\')\n                open++;\n            else {\n                if (open > 0)\n                    open--;\n                else\n                    mismatch++;\n            }\n        }\n        return open + mismatch;\n    }\n};\n```C# code\npublic class Solution {\n    public int MinAddToMakeValid(string s) {\n        int open = 0, mismatch = 0;\n        for (int i = 0; i < s.Length; i++) {\n            if (s[i] == \'(\')\n                open++;\n            else {\n                if (open > 0)\n                    open--;\n                else\n                    mismatch++;\n            }\n        }\n        return open + mismatch;\n    }\n}\n````Python code\nclass Solution(object):\n    def minAddToMakeValid(self, s):\n        """\n        :type s: str\n        :rtype: int\n        """\n        open_brackets = 0\n        mismatch = 0\n        for char in s:\n            if char == \'(\':\n                open_brackets += 1\n            else:\n                if open_brackets > 0:\n                    open_brackets -= 1\n                else:\n                    mismatch += 1\n        return open_brackets + mismatch\n\n
['Array', 'String Matching', 'Python', 'C++', 'Java', 'C#']