-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f86950c
commit 06fd450
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
1190-reverse-substrings-between-each-pair-of-parentheses/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<h2><a href="https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses">1190. Reverse Substrings Between Each Pair of Parentheses</a></h2><h3>Medium</h3><hr><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> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "(abcd)" | ||
<strong>Output:</strong> "dcba" | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "(u(love)i)" | ||
<strong>Output:</strong> "iloveu" | ||
<strong>Explanation:</strong> The substring "love" is reversed first, then the whole string is reversed. | ||
</pre> | ||
|
||
<p><strong class="example">Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "(ed(et(oc))el)" | ||
<strong>Output:</strong> "leetcode" | ||
<strong>Explanation:</strong> First, we reverse the substring "oc", then "etco", and finally, the whole string. | ||
</pre> | ||
|
||
<p> </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> |