C++ using stack
\nclass Solution {\npublic:\n    string removeOuterParentheses(string S) {\n        stack<char> ss;\n        string ans = "";\n        \n        for(char c: S) 
```\nclass Solution {\npublic:\n    string removeOuterParentheses(string S) {\n        stack<char> ss;\n        string ans = "";\n        \n        for(char c: S) {\n            if(ss.empty() && c==\'(\') {\n                ss.push(c);\n            } else if(ss.size() == 1 && c==\')\') {\n                ss.pop();\n            } else if(c==\'(\') {\n                ss.push(c);\n                ans+=c;\n            } else if(c==\')\') {\n                ss.pop();\n                ans+=c;\n            }\n        }\n        \n        return ans;\n    }\n};\n```
[]