Simple Java Solution using stack
\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        if(s.length() == 0 || s == null){\n            return "";\n        }\n        St
```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        if(s.length() == 0 || s == null){\n            return "";\n        }\n        StringBuilder sb = new StringBuilder(s);\n        \n        Stack<Integer> st = new Stack<>();\n        \n        for(int i = 0; i < s.length(); ++i){\n            \n            char ch = s.charAt(i);\n            \n            if(ch == \'(\'){\n                st.push(i);\n            }else if(ch == \')\'){\n                if(st.size() == 0){\n                    st.push(i);\n                }else{\n                    if(s.charAt(st.peek()) == \'(\'){\n                        st.pop();// this makes a pair of valid parenthesis\n                    }else{\n                        st.push(i); // this makes "))"\n                    }\n                }\n            }\n        }\n        \n        while(st.size() > 0){\n            sb.deleteCharAt(st.pop()); // remove invalid at the indices\n        }\n        \n        return sb.toString();\n        \n    }\n}\n```\n\n
['Stack', 'Java']