2019年4月8日 1021. Remove Outermost Parentheses

class Solution(object):
    def removeOuterParentheses(self, S):
        """
        :type S: str
        :rtype: str
        """
        mark = 0
        ret = ''
        for i in S:
            if i == '(':
                if mark == 0:
                    mark = 1
                    continue
                mark += 1
            elif i == ')':
                mark -= 1
                        
            if mark > 0:
                ret += i
                
        return ret
原文地址:https://www.cnblogs.com/seenthewind/p/10668616.html