A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and +represents string concatenation. For example, "", "()", "(())()", and …
class Solution(object): def removeOuterParentheses(self, S: str) -> str: li = list() bcode = 0 temp = '' result = '' for i in range(len(S)): if S[i]=='(': bcode -= 1 else: bcode += 1 temp += S[i] if bcode == 0: li.append(temp) temp = '' for j in rang…