FastPrepReverse Substrings Between Parentheses
Problems/Reverse Substrings Between Parentheses

Reverse Substrings Between Parentheses

Rippling logoRippling● MediumNEW GRADOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report identifies the standard reverse-substrings-in-parentheses exercise. Alphabet, balanced-input guarantees and bounds are practice conventions; core source match is about 90%.

Given a string s containing lowercase English letters and balanced parentheses, reverse the characters inside every matched pair of parentheses, starting with the innermost pairs. Return the resulting string with all parentheses removed.

Empty input and empty parenthesis contents are valid.

Function

reverseParentheses(s: String) → String

Examples

Example 1

s = "(abcd)"return = "dcba"

Reverse the only parenthesized substring.

Example 2

s = "(u(love)i)"return = "iloveu"

The inner reversal produces evol; reversing uevoli produces iloveu.

Example 3

s = "a(bc)d"return = "acbd"

Only the letters bc are reversed; surrounding letters keep their order.

Constraints

  • 0 <= s.length <= 2000.
  • s contains lowercase English letters and balanced (, ) characters only.

More Rippling problems

  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All Rippling interview questionsSee Rippling hiring insights
Saved
public String reverseParentheses(String s) {
    // Write your code here.
}
Checking account…