mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
<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>Given a <strong>balanced</strong> string <code>s</code>, split it into some number of substrings such that:</p>
|
||||
|
||||
<p>Return <em>the maximum amount of split <strong>balanced</strong> strings</em>.</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>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "RLRRLLRLRL"
|
||||
@@ -13,15 +17,15 @@
|
||||
<strong>Explanation:</strong> s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "RLLLLRRRLR"
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> s can be split into "RL", "LLLRRR", "LR", each substring contains same number of 'L' and 'R'.
|
||||
</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>Example 3:</strong></p>
|
||||
<p><strong class="example">Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "LLLLRRRR"
|
||||
@@ -33,7 +37,7 @@
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 1000</code></li>
|
||||
<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>
|
||||
|
Reference in New Issue
Block a user