|
| 1 | +<h2>unknown-problem</h2><h3>Easy</h3><hr><div><p><i data-stringify-type="italic">Balanced</i> strings are those who have equal quantity of 'L' and 'R' characters.</p> |
| 2 | + |
| 3 | +<p>Given a balanced string <code data-stringify-type="code">s</code> split it in the maximum amount of balanced strings.</p> |
| 4 | + |
| 5 | +<p>Return the maximum amount of splitted balanced strings.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strong>Example 1:</strong></p> |
| 9 | + |
| 10 | +<pre><strong>Input:</strong> s = "RLRRLLRLRL" |
| 11 | +<strong>Output:</strong> 4 |
| 12 | +<strong>Explanation: </strong>s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'. |
| 13 | +</pre> |
| 14 | + |
| 15 | +<p><strong>Example 2:</strong></p> |
| 16 | + |
| 17 | +<pre><strong>Input:</strong> s = "RLLLLRRRLR" |
| 18 | +<strong>Output:</strong> 3 |
| 19 | +<strong>Explanation: </strong>s can be split into "RL", "LLLRRR", "LR", each substring contains same number of 'L' and 'R'. |
| 20 | +</pre> |
| 21 | + |
| 22 | +<p><strong>Example 3:</strong></p> |
| 23 | + |
| 24 | +<pre><strong>Input:</strong> s = "LLLLRRRR" |
| 25 | +<strong>Output:</strong> 1 |
| 26 | +<strong>Explanation: </strong>s can be split into "LLLLRRRR". |
| 27 | +</pre> |
| 28 | + |
| 29 | +<p><strong>Example 4:</strong></p> |
| 30 | + |
| 31 | +<pre><strong>Input:</strong> s = "RLRRRLLRLL" |
| 32 | +<strong>Output:</strong> 2 |
| 33 | +<strong>Explanation: </strong>s can be split into "RL", "RRRLLRLL", since each substring contains an equal number of 'L' and 'R' |
| 34 | +</pre> |
| 35 | + |
| 36 | +<p> </p> |
| 37 | +<p><strong>Constraints:</strong></p> |
| 38 | + |
| 39 | +<ul> |
| 40 | + <li><code>1 <= s.length <= 1000</code></li> |
| 41 | + <li><code>s[i] = 'L' or 'R'</code></li> |
| 42 | +</ul> |
| 43 | +</div> |
0 commit comments