java solution
\nclass Solution {\n    public String removeOuterParentheses(String S) {\n        if(S == null) return "";\n        char[] chars = S.toCharArray();\n        int
```\nclass Solution {\n    public String removeOuterParentheses(String S) {\n        if(S == null) return "";\n        char[] chars = S.toCharArray();\n        int stack = 0;\n\n        StringBuilder builder = new StringBuilder();\n        for(int i=0; i<chars.length; i++){\n            if (chars[i] == 40) {\n                stack ++;\n                if(stack != 1) builder.append(chars[i]);\n            } else if (chars[i] == 41) {\n                stack --;\n                if(stack != 0) builder.append(chars[i]);\n            }\n        }\n\n        return builder.toString();\n    }\n}\n```\n\n\nI use an \u201Cint stack\u201D to simulate the use of the stack.
[]