Advertisement
nikunjsoni

1021

Mar 22nd, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     string removeOuterParentheses(string S) {
  4.         string res;
  5.         int count=0;
  6.         for(char c: S){
  7.             if(c == '(' && count++ > 0) res += c;
  8.             if(c == ')' && count-- > 1) res += c;
  9.         }
  10.         return res;
  11.     }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement