java.lang.Object
g1101_1200.s1190_reverse_substrings_between_each_pair_of_parentheses.Solution

public class Solution extends Object
1190 - Reverse Substrings Between Each Pair of Parentheses.<p>Medium</p> <p>You are given a string <code>s</code> that consists of lower case English letters and brackets.</p> <p>Reverse the strings in each pair of matching parentheses, starting from the innermost one.</p> <p>Your result should <strong>not</strong> contain any brackets.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;(abcd)&rdquo;</p> <p><strong>Output:</strong> &ldquo;dcba&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;(u(love)i)&rdquo;</p> <p><strong>Output:</strong> &ldquo;iloveu&rdquo;</p> <p><strong>Explanation:</strong> The substring &ldquo;love&rdquo; is reversed first, then the whole string is reversed.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;(ed(et(oc))el)&rdquo;</p> <p><strong>Output:</strong> &ldquo;leetcode&rdquo;</p> <p><strong>Explanation:</strong> First, we reverse the substring &ldquo;oc&rdquo;, then &ldquo;etco&rdquo;, and finally, the whole string.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 2000</code></li> <li><code>s</code> only contains lower case English characters and parentheses.</li> <li>It is guaranteed that all parentheses are balanced.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • reverseParentheses

      public String reverseParentheses(String s)