✅ Python Easy prefix count
The approach is quite simple\n1. To add the opening (, we have to see the future, how many closing ) are at right side in order to make it valid, so we count it
The approach is quite simple\n1. To add the opening ```(```, we have to see the future, how many closing ```)``` are at right side in order to make it valid, so we count it. if we have some closing at right then only we can add the opening.\n2. To add the closing ```)``` we have to count how many opening```(``` we had at left side waiting for closing ```)```. If no one is waiting why would we add it.\n```\nclass Solution:\n    def minRemoveToMakeValid(self, s: str) -> str:\n        closing, opening, ans = s.count(\')\'), 0, \'\'\n        for i in s:\n            if i == \'(\':\n                opening += 1\n                if opening <= closing: ans += \'(\'\n            elif i == \')\':\n                if opening > 0: ans += \')\'\n                closing -= 1; opening -= 1\n                if opening < 0: opening = 0\n            else: ans += i\n        return ans\n```
['Python', 'Python3']