😎💥
Code\n\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        int startPointer = 0;\n        int endPointer = s.length() - 1;\n\n       
# Code\n```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        int startPointer = 0;\n        int endPointer = s.length() - 1;\n\n        String result;\n        char[] arr = s.toCharArray();\n        int openParenthesesCount = 0;\n        for (int i = 0; i < arr.length; i++) {\n            if (arr[i] == \'(\')\n                openParenthesesCount++;\n            else if (arr[i] == \')\') {\n                if (openParenthesesCount == 0)\n                    arr[i] = \'*\'; \n                else\n                    openParenthesesCount--;\n            }\n        }\n        for (int i = arr.length - 1; i >= 0; i--) {\n            if (openParenthesesCount > 0 && arr[i] == \'(\') {\n                arr[i] = \'*\'; \n                openParenthesesCount--;\n            }\n        }\n                int p = 0; \n        for (int i = 0; i < arr.length; i++) {\n            if (arr[i] != \'*\')\n                arr[p++] = arr[i];\n        }\n        result = new String(arr).substring(0, p);\n\n        return result;\n    }\n}\n```
['Java']