Easy C++ Solution || Beginner Friendly ✅✅
\n# Approach\nThis question is all about the counter. As the very first bracket would start from 0 and thus that will not be included and the last outermost bra
\n# Approach\nThis question is all about the counter. As the very first bracket would start from 0 and thus that will not be included and the last outermost bracket with value 0 will also be not included.\n\nIn this way we will check whether the char should be added into the string or not. \nAdd 1 if there is \'(\' open parenthesis. and sub 1 if  \')\' clsed paranthesis.\n\nFor eg.\n    \n![01.png](https://assets.leetcode.com/users/images/0aec98a5-dfdc-452d-9417-ad1e1bacf6eb_1691679008.493465.png)\n\n\nIn above explanation, wherever the count is zero. We are not adding that in string.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s) {\n        string ans="";\n        int c=0;\n        for(char ch:s){\n            if(ch==\'(\' && c==0){\n                //skip, as this would be the first bracket so it will be considered as outermost bracket\n                c++;\n            }\n            else if(ch==\'(\' && c>=1){\n                ans+=ch;\n                c++;\n                //add ch in the string\n            }\n            else if(ch==\')\' && c>1){\n                //sub ch in the string, as it\'s pair is alrrady added\n                ans+=ch;\n                c--;\n            }\n            else if(ch==\')\' && c==1){\n                //skip it, outermost bracket\n                c--;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']