[c++] two solution stack and with out stack(only slight modification in stack sol.)
please upVote my solution if you like it.\n\nMy first solution is stack based and it consume more memory than with out stack solution in my second solution to e
please **upVote** my solution if you like it.\n\nMy first solution is stack based and it consume more memory than with out stack solution in my second solution to elemenate stack from it so please reffer to that also \n\n\n\'\'\'\nclass Solution {\npublic:\n\n    string removeOuterParentheses(string S) {\n        stack<char>st;\n        string ans;\n        for(auto a:S)\n        {\n            if(a==\'(\')\n            {\n                if(st.size()>0)\n                {\n                    ans+=\'(\';\n                }\n                st.push(\'(\');\n            }\n            else\n            {\n                if(st.size()>1)\n                {\n                    ans+=\')\';\n                }\n                st.pop();\n            }\n        }\n        return ans;\n    }\n};\n\'\'\'\n\nSolution without stack \n\n\'\'\'\nclass Solution {\npublic:\n\n    string removeOuterParentheses(string S) {\n        int st=0;\n        string ans;\n        for(auto a:S)\n        {\n            if(a==\'(\')\n            {\n                if(st>0)\n                {\n                    ans+=\'(\';\n                }\n                st++;\n            }\n            else\n            {\n                if(st>1)\n                {\n                    ans+=\')\';\n                }\n                st--;\n            }\n        }\n        return ans;\n    }\n};\n\'\'\'
['Stack', 'C']