Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. class Solution:
  2. def removeOuterParentheses(self, S: str) -> str:
  3.  
  4. cnt = 0
  5. ans = ""
  6. begin = 0
  7.  
  8. for i, s in enumerate(S):
  9. if s == "(":
  10. cnt += 1
  11. else:
  12. cnt -= 1
  13. if cnt == 0:
  14. ans += S[begin+1:i]
  15. begin = i+1
  16. return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement