[JAVA] beats 98%, simple  iterative solution
\nclass Solution {\n    public String removeOuterParentheses(String S) {\n        StringBuilder sb = new StringBuilder();\n        int counter = 0;\n        for
```\nclass Solution {\n    public String removeOuterParentheses(String S) {\n        StringBuilder sb = new StringBuilder();\n        int counter = 0;\n        for(char c : S.toCharArray()){\n            if(c == \'(\'){\n                if(counter != 0) sb.append(c);\n                counter++;\n            }\n            else{\n                counter--;\n                if(counter != 0) sb.append(c);\n            }\n        }\n        \n        return sb.toString();\n    }\n}\n```
['Java']