[JAVA] [STACK / STRINGBUILDER]
```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n         Stack stack = new Stack<>();\n       StringBuilder stringBuilder = new Strin
```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n         Stack<Integer> stack = new Stack<>();\n       StringBuilder stringBuilder = new StringBuilder(s); //a)b(c)d"\n       for(int i = 1;i<=s.length();i++){\n           if(s.charAt(i-1) == \'(\')\n               stack.push(i);\n           else if(s.charAt(i-1) == \')\' && !stack.empty())\n               stack.pop();\n           else if(s.charAt(i-1) ==\')\' && stack.empty()){//))((\n               stringBuilder.replace(i-1,i, "0");\n           }\n       }\n      \n       while (!stack.empty()){\n           stringBuilder.deleteCharAt(stack.pop()-1);\n       }\n       return stringBuilder.toString().\n               replace(\'0\',\' \').\n               replaceAll("\\\\s+","");\n    }\n}
['Stack', 'Java']