Easy Java Solution | O(N) time
Upvote if you Got It \uD83D\uDE42\nclass Solution {\n\n    public String minRemoveToMakeValid(String s) {\n        Stack st = new Stack<>();\n        StringBuil
**Upvote if you Got It** \uD83D\uDE42\nclass Solution {\n\n    public String minRemoveToMakeValid(String s) {\n        Stack<Integer> st = new Stack<>();\n        StringBuilder sb = new StringBuilder(s);\n\t\t\n        for(int i=0;i<s.length();i++){\n            if(s.charAt(i)==\'(\')\n                st.push(i);\n            else if(s.charAt(i)==\')\'){\n                if(!st.isEmpty() && s.charAt(st.peek())==\'(\')\n                    st.pop();\n                else\n                    st.push(i);\n            }\n        }\n        while(!st.isEmpty())\n            sb.deleteCharAt(st.pop());\n        return sb.toString();\n    }\n}
['Stack', 'Java']