Remove Outermost Parentheses

PHOTO EMBED

Sat Oct 08 2022 15:33:48 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    string removeOuterParentheses(string s) 
    {
        int n=s.size();
        int j=0;
        string p="";
        for(int i=0;i<n;i++)
        {
            if(s[i]==41)
            {
                j--;
            }
            if(j!=0) 
            {
                p+=s[i];
            }
            if(s[i]==40)
            {
                j++;
            }
            
        }
        return p;
    }
};
content_copyCOPY

Do it again

https://leetcode.com/problems/remove-outermost-parentheses/