C++ stack and without stack solutions.
Stack implementation\n\nclass Solution {\npublic:\n    string removeOuterParentheses(string s)\n    {\n        stack<char>sc;\n        string ans;\n        for(
**Stack implementation**\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s)\n    {\n        stack<char>sc;\n        string ans;\n        for(char i:s)\n        {\n            if(i == \'(\')\n            {\n                if(sc.size() > 0)\n                {\n                    ans += i;\n                }\n                sc.push(i);\n            }\n            else\n            {\n                if(sc.size() > 1)\n                {\n                    ans += i;\n                }\n                sc.pop();\n            }\n        }\n        return ans;\n    }\n};\n```\n**Without stack implementation**\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s)\n    {\n        int count = 0;\n        string ans;\n        for(char i:s)\n        {\n            if(i == \'(\')\n            {\n                if(count > 0)\n                {\n                    ans += i;\n                }\n                count++;\n            }\n            else\n            {\n                if(count > 1)\n                {\n                    ans += i;\n                }\n                count--;\n            }\n        }\n        return ans;\n    }\n};\n```\n**Like the solution?\nPlease upvote \u30C4**
['Stack', 'C', 'C++']