Simple | JAVA |  Using Stack
\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        \n        \n        Stack<Integer> st= new Stack<>();  //to check for valid pare
```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        \n        \n        Stack<Integer> st= new Stack<>();  //to check for valid parentheses\n        char[] ch=s.toCharArray();   \n        \n    //this for loop make valid ch array and containing \'.\' you can use anything for flag\n        for(int i=0;i<ch.length;i++){\n            \n            if(ch[i]==\'(\'){\n                st.push(i);\n            }else if(ch[i] == \')\'){\n                if(st.size()==0){\n                    ch[i]=\'.\';\n                }else\n                    st.pop();\n            }\n            \n                       \n        }\n        \n        \n        //remaining elements in stack\n        while(st.size()>0){\n            ch[st.pop()] =\'.\';\n        }\n        \n        \n        //store arrays ch int string for returning the valid string\n        StringBuilder str = new StringBuilder();\n        for(char c : ch){\n            if(c!=\'.\'){\n                str.append(c);\n            }\n        }\n        \n        \n        return str.toString();\n    }\n}\n```
['String', 'Stack', 'Java']