100% fastest solution | Explained every line | Efficient | Easy to understand | cpp | O(n)
100% fastest solution | Explained every line | Efficient | Easy to understand | cpp | O(n)\n\nclass Solution {\npublic:\n    string removeOuterParentheses(strin
100% fastest solution | Explained every line | Efficient | Easy to understand | cpp | O(n)\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s) \n    {\n        string ans;\n        stack<char> st;\n\n        for(auto x: s)\n        {\n            if(x==\'(\')   // 1. ->add to stack    2. -> add to ans if not outermost\n            {\n                if(st.size()>0)\n                    ans.push_back(x);\n                st.push(x);\n            }\n            else  // 1. -> pop    2. -> add to ans if not empty\n            {\n                st.pop();\n                if(!st.empty())\n                    ans.push_back(x);\n            }\n        }\n        return ans;\n    }\n};```
['Stack', 'C', 'C++']