Easy solution 🚀| Detailed explanation☑️☑️ | Beginner friendly 📍|
Approach\n1. Initialization:\n\n- Initialize an empty string ans to store the result.\n2. Iterating Over Characters:\n\n- We will Iterate through each character
# Approach\n1. Initialization:\n\n- Initialize an empty string ans to store the result.\n2. Iterating Over Characters:\n\n- We will Iterate through each character ch in the input string s.\n3. Tracking Parentheses Count:\n\n- Maintain a variable count to keep track of the current nesting level of parentheses.\n- When encountering an opening parenthesis \'(\' and the count is 0, increment the count and ignore adding this parenthesis to the result since it\'s the outermost one.\n- When encountering an opening parenthesis \'(\' and the count is greater than or equal to 1, increment the count and append the parenthesis to the result. This represents an inner parenthesis.\n- When encountering a closing parenthesis \')\' and the count is greater than 1, append the parenthesis to the result and decrement the count. This represents an inner parenthesis.\n- When encountering a closing parenthesis \')\' and the count is exactly 1, decrement the count without appending to the result, as it represents the outermost closing parenthesis.\n4. Return Result:\n\n- Lastly return the string ans, which contains the desired string without the outermost parentheses.\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string s) {\n       // int n = s.size();\n        string ans="";\n        int count = 0;\n        for(char ch:s)\n        {\n            if(ch==\'(\' && count==0)\n            {\n                count++;\n            }\n            else if(ch==\'(\' && count>=1)\n            {\n                ans = ans + ch;\n                count++;\n            }\n            else if(ch==\')\' && count>1)\n            {\n                ans = ans + ch;\n                count--;\n            }\n            else if(ch==\')\' && count==1)\n            {\n                count--;\n            }\n        }\n        return ans;\n    }\n};\n```\n\n![upvote.jpg](https://assets.leetcode.com/users/images/a44dc151-0b0a-449f-896e-7d4915b38b37_1709099735.465367.jpeg)\n
['String', 'C++']