Remove Outermost Parentheses

easy
1. You are given a valid parentheses string in form of A+B+C... where A, B and C are valid primitive strings.
2. A primitive string is a valid parentheses string which cant is split in s = x+y, with x and y nonempty valid parentheses strings.
3. You have to remove the outermost parentheses from all primitive strings.

Example "(()())(())" = "(()())" + "(())".
removing outermost parentheses from "(()())" and "(())" will result in ()()().

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1. s.length <= 10000
2. s[i] is "(" or ")"
3. s is a valid parentheses string

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
(()())(())
Output
()()()
Previous
Design Circular Deque

Related Questions