Concept of these kind of problems | Simple |
problem similar to Google Hashcode 2020 Qualification round\nThe key in these types of problems is to have a variable named depth, and increment and decrement i
problem similar to Google Hashcode 2020 Qualification round\nThe key in these types of problems is to have a variable named depth, and increment and decrement it accordingly [ \'(\' depth increases ] \nHere whenver the depth is currently zero we ignore it, and when it is again going to be zero after a series of open and closing parenthesis we ignore it again. \n\n```\nclass Solution {\npublic:\n    string removeOuterParentheses(string S) {\n        int depth=0;\n        string p;\n        for(int i=0;i<S.length();i++){\n            if (S[i]==\'(\') {\n\t\t\t\tif (depth!=0){\n                    p+=\'(\';\n\t\t\t\t}\n                depth+=1;\n\t\t\t}\n            if (S[i]==\')\'){\n\t\t\t\tif (depth-1!=0){\n                    p+=\')\';\n\t\t\t\t}\n                depth-=1;\n\t\t\t}    \n        }\n        return p;\n    }\n};
[]