0 ms C++ Approach
Intuition\n Describe your first thoughts on how to solve this problem. \nA valid string has equal number of \'(\' and \')\' braces. So if we keep count of numbe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nA valid string has equal number of \'(\' and \')\' braces. So if we keep count of number of opening and closing braces, we can check for a valid parenthesis easily.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe took a count variable and incremented its value by 1 when found \'(\' and decremented its value by 1 when found \')\'. Now if our count variable has value 1 and we are on \'(\' , this means it is our outermost parenthesis and it should not be included in our answer. Similarily if count variable has value 0 and our iterator is pointing to \')\', this means this is a closing outer parenthesis , so it will be ignored. And for all other cases we update our result.\n\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s) {\n        string res="";\n        int count=0;\n        int size=s.size();\n        for(int i=0;i<size;i++){\n            if(s[i]==\'(\')\n                count++;\n            else\n                count--;\n                \n            if((count==1 && s[i]==\'(\') || (count==0 && s[i]==\')\')) \n                continue;\n            else\n                res+=s[i];\n        }\n        return res;\n    }\n};\n```
['C++']