Super simple Python solution with explanation. Faster than 100%, Memory Usage less than 100%
Convert string to list, because String is an immutable data structure in Python and it\'s much easier and memory-efficient to deal with a list for this task.\n2
1. Convert string to list, because String is an immutable data structure in Python and it\'s much easier and memory-efficient to deal with a list for this task.\n2. Iterate through list\n3. Keep track of indices with open parentheses in the stack. In other words, when we come across open parenthesis we add an index to the stack.\n4. When we come across close parenthesis we pop an element from the stack. If the stack is empty we replace current list element with an empty string\n5. After iteration, we replace all indices we have in the stack with empty strings, because we don\'t have close parentheses for them.\n6. Convert list to string and return\n\n```\ndef minRemoveToMakeValid(self, s: str) -> str:\n    s = list(s)\n    stack = []\n    for i, char in enumerate(s):\n        if char == \'(\':\n            stack.append(i)\n        elif char == \')\':\n            if stack:\n                stack.pop()\n            else:\n                s[i] = \'\'\n    while stack:\n        s[stack.pop()] = \'\'\n    return \'\'.join(s)\n```\n\nTime complexity is O(n)\nMemory complexity is O(n)
['Python', 'Python3']