Preview:
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;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter