Back to problems

Reverse Substrings Between Each Pair of Parentheses

Algorithm · Okta · Medium

Examples Example 1 Example 2 Requirements You are given a string consisting solely of lowercase English letters and balanced parentheses. Perform the following transformation: For every matching pair of parentheses, reverse the substring that lies between them. If parentheses are nested, resolve the innermost pair first and work outward. After all reversals are complete, remove every parenthesis from the string and return the result. Preparation Implement the…

Checking your access…