Easy Solution in C++
\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n
\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n\n        int lwait = 0;\n        int rwait = 0;\n        for(char c : s){\n            if(c == \')\'){\n                rwait++;\n                if(lwait > 0) {\n                    rwait = rwait - 1;\n                    lwait--;\n                }\n                continue;\n            }\n            lwait++;\n        }\n        return lwait+rwait;\n\n        \n    }\n};\n```
['C++']