|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1221. Split a String in Balanced Strings |
5 |
| - * |
6 |
| - * Balanced strings are those who have equal quantity of 'L' and 'R' characters. |
7 |
| - * Given a balanced string s split it in the maximum amount of balanced strings. |
8 |
| - * Return the maximum amount of splitted balanced strings. |
9 |
| - * |
10 |
| - * Example 1: |
11 |
| - * Input: s = "RLRRLLRLRL" |
12 |
| - * Output: 4 |
13 |
| - * Explanation: s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'. |
14 |
| - * |
15 |
| - * Example 2: |
16 |
| - * Input: s = "RLLLLRRRLR" |
17 |
| - * Output: 3 |
18 |
| - * Explanation: s can be split into "RL", "LLLRRR", "LR", each substring contains same number of 'L' and 'R'. |
19 |
| - * |
20 |
| - * Example 3: |
21 |
| - * Input: s = "LLLLRRRR" |
22 |
| - * Output: 1 |
23 |
| - * Explanation: s can be split into "LLLLRRRR". |
24 |
| - * |
25 |
| - * Example 4: |
26 |
| - * Input: s = "RLRRRLLRLL" |
27 |
| - * Output: 2 |
28 |
| - * Explanation: s can be split into "RL", "RRRLLRLL", since each substring contains an equal number of 'L' and 'R' |
29 |
| - * |
30 |
| - * Constraints: |
31 |
| - * 1 <= s.length <= 1000 |
32 |
| - * s[i] = 'L' or 'R' |
33 |
| - * */ |
34 | 3 | publicclass_1221 {
|
35 | 4 | publicstaticclassSolution1 {
|
36 | 5 | publicintbalancedStringSplit(Strings) {
|
|