-
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
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
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,41 @@ | ||
<h2><a href="https://leetcode.com/problems/split-a-string-in-balanced-strings/">1221. Split a String in Balanced Strings</a></h2><h3>Easy</h3><hr><div><p><strong>Balanced</strong> strings are those that have an equal quantity of <code>'L'</code> and <code>'R'</code> characters.</p> | ||
|
||
<p>Given a <strong>balanced</strong> string <code>s</code>, split it into some number of substrings such that:</p> | ||
|
||
<ul> | ||
<li>Each substring is balanced.</li> | ||
</ul> | ||
|
||
<p>Return <em>the <strong>maximum</strong> number of balanced strings you can obtain.</em></p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre><strong>Input:</strong> s = "RLRRLLRLRL" | ||
<strong>Output:</strong> 4 | ||
<strong>Explanation:</strong> s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre><strong>Input:</strong> s = "RLRRRLLRLL" | ||
<strong>Output:</strong> 2 | ||
<strong>Explanation:</strong> s can be split into "RL", "RRRLLRLL", each substring contains same number of 'L' and 'R'. | ||
Note that s cannot be split into "RL", "RR", "RL", "LR", "LL", because the 2<sup>nd</sup> and 5<sup>th</sup> substrings are not balanced.</pre> | ||
|
||
<p><strong class="example">Example 3:</strong></p> | ||
|
||
<pre><strong>Input:</strong> s = "LLLLRRRR" | ||
<strong>Output:</strong> 1 | ||
<strong>Explanation:</strong> s can be split into "LLLLRRRR". | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>2 <= s.length <= 1000</code></li> | ||
<li><code>s[i]</code> is either <code>'L'</code> or <code>'R'</code>.</li> | ||
<li><code>s</code> is a <strong>balanced</strong> string.</li> | ||
</ul> | ||
</div> |