Beginner friendly [Java/JavaScript/Python] solution
Time Complexity : O(n)\nJava\n\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        StringBuilder sb = new StringBuilder(s);\n        
**Time Complexity : O(n)**\n**Java**\n```\nclass Solution {\n    public String minRemoveToMakeValid(String s) {\n        StringBuilder sb = new StringBuilder(s);\n        Stack<Integer> stack = new Stack<>();\n        for(int i=0; i<s.length(); i++){\n            if(sb.charAt(i) == \'(\')     stack.push(i);\n            else if (sb.charAt(i) == \')\'){\n                if(!stack.isEmpty())    stack.pop();\n                else sb.setCharAt(i, \'*\');\n            }\n        }\n        while(!stack.isEmpty()) sb.setCharAt(stack.pop(), \'*\');\n        return sb.toString().replaceAll("\\\\*", "");\n    }\n}\n```\n**JavaScript**\n```\nvar minRemoveToMakeValid = function(s) {\n    s = s.split("")\n    let stack = []\n    for(let i=0; i<s.length; i++){\n        if(s[i] == "(")     stack.push(i)\n        else if (s[i] == ")"){\n            if(stack.length)    stack.pop()\n            else s[i] = ""\n        }\n    }\n    for(let i of stack) s[i] = ""\n    return s.join("")\n};\n```\n**Python**\n```\nclass Solution(object):\n    def minRemoveToMakeValid(self, s):\n        s = list(s)\n        stack = []\n        for i in range(len(s)):\n            if s[i] == "(":\n                stack.append(i)\n            elif s[i] == ")":\n                if len(stack):\n                    stack.pop()\n                else:\n                    s[i] = ""\n        for i in stack:\n            s[i] = ""\n        return "".join(s)\n\n```
['Python', 'Java', 'JavaScript']