s is a valid string made only of ( and ). Split it into primitive groups: the shortest non-empty balanced pieces, such as () and (()), read from left to right. Remove the outermost parentheses of every group and join what is left.
For example "(()())(())" is the groups (()()) and (()), which become ()() and (): the answer is "()()()".
Example 1
Input:
remove_outer_parentheses('(()())(())')
Output:
'()()()'
Example 2
Input:
remove_outer_parentheses('()()')
Output:
''
0 <= len(s) <= 3 * 10**5s is balanced and contains only ( and ).No results yet
Run your code to check it against the examples, or submit to run every test.