Best O(N) Solution
\n\n# Approach\nBest Approach\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    string removeOu
\n\n# Approach\nBest Approach\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s) {\n        int count = 0;\n        string ans = "";\n        for (int i = 0; i < s.size(); i++) {\n            if (s[i] == \'(\') {\n                if (count > 0)\n                    ans += s[i]; \n                count++;\n            }\n            if (s[i] == \')\') {\n                if (count > 1)\n                    ans += s[i];\n                count--;\n            }       \n        }\n        return ans;\n    }\n};\n```
['C++']