Reverse Substrings Between Each Pair Of Parentheses

medium
1: You are given a string s that consists of lower case English letters and brackets. 
2: Reverse the strings in each pair of matching parentheses, starting from the innermost one.
3: Your result should not contain any brackets.

Example
(abcd) -> dcba
(u(love)i) -> iloveu
(gni(pc(do))ep) -> pepcoding

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1: 0 <= s.length <= 2000
2: s only contains lower case English characters and parentheses
3: It's guaranteed that all parentheses are balanced.

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
(gni(pc(do))ep)
Output
pepcoding
Previous
Score Of Parentheses
Next
Minimum Remove To Make Valid Parentheses

Related Questions