Simple O(n) Java solution
Thanks to fengyunzhe90.\n\n```\nclass Solution {\n    public String removeOuterParentheses(String s) {\n        Stack stack = new Stack<>();\n        \n        
Thanks to fengyunzhe90.\n\n```\nclass Solution {\n    public String removeOuterParentheses(String s) {\n        Stack<Character> stack = new Stack<>();\n        \n        String result = "";\n        \n        for (int i = 0; i < s.length(); i++) {\n            char c = s.charAt(i);\n            \n            if (stack.isEmpty() && c == \'(\') {\n                stack.push(c);\n                continue;\n            }\n            \n            if (stack.size() == 1 && c == \')\') {\n                stack.pop();\n                continue;\n            }\n            \n            if (c == \'(\') {\n                stack.push(c);\n            }\n            \n            if (c == \')\') {\n                stack.pop();\n            }\n            result += c + "";\n        }\n\n        return result;\n    }\n} ;
[]