Easy to follow approach using Stack - O(n) Time and Space
Approach using Stack\n\nStep 1: Iterate through the string to identify and mark invalid closing parentheses and remember the positions of unmatched opening pare
# Approach using Stack\n\n**Step 1:** Iterate through the string to identify and mark invalid closing parentheses and remember the positions of unmatched opening parentheses using a stack.\n\n**Step 2:** Remove any unmatched opening parentheses recorded in the stack. \n\n# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```python\nclass Solution:\n    def minRemoveToMakeValid(self, s: str) -> str:\n        s = list(s)\n        stack = []\n        for i, c in enumerate(s):\n            if c == "(":\n                stack.append(i)\n            elif c == ")":\n                if not stack:\n                    s[i] = ""\n                else:\n                    stack.pop()\n        while stack:\n            s[stack.pop()] = ""\n        return "".join(s)\n        \n```
['Stack', 'Python3']