Class Solution
java.lang.Object
g1201_1300.s1221_split_a_string_in_balanced_strings.Solution
1221 - Split a String in Balanced Strings.<p>Easy</p>
<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 in the maximum amount of balanced strings.</p>
<p>Return <em>the maximum amount of split <strong>balanced</strong> strings</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “RLRRLLRLRL”</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> s can be split into “RL”, “RRLL”, “RL”, “RL”, each substring contains same number of ‘L’ and ‘R’.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “RLLLLRRRLR”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> s can be split into “RL”, “LLLRRR”, “LR”, each substring contains same number of ‘L’ and ‘R’.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “LLLLRRRR”</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> s can be split into “LLLLRRRR”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= 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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
balancedStringSplit
-