Practice Reverse Substrings Between Each Pair of Parentheses
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a string s that consists of lower case English letters and brackets. Reverse the strings in each pair of matching parentheses, starting from the innermost one. Your result should not contain any brackets.
Source: Reverse Substrings Between Each Pair of Parentheses on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "(abcd)"
Output
"dcba"
# Example 2
Input
s = "(u(love)i)"
Output
"iloveu"
# Example 3
Input
s = "(ed(et(oc))el)"
Output
"leetcode"
Constraints
1 <= s.length <= 2000
s only contains lower case English characters and parentheses.
It is guaranteed that all parentheses are balanced.
Related LeetCode Problems
Practice more problems similar to Reverse Substrings Between Each Pair of Parentheses.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.