LeetCode --- 1221. Split a String in Balanced Strings 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1221. Split a String in Balanced Strings 解题报告相关的知识,希望对你有一定的参考价值。

Balanced strings are those that have an equal quantity of \'L\' and \'R\' characters.

Given a balanced string s, split it in the maximum amount of balanced strings.

Return the maximum amount of split balanced strings.

Example 1:

Input: s = "RLRRLLRLRL"
Output: 4
Explanation: s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of \'L\' and \'R\'.

Example 2:

Input: s = "RLLLLRRRLR"
Output: 3
Explanation: s can be split into "RL", "LLLRRR", "LR", each substring contains same number of \'L\' and \'R\'.

Example 3:

以上是关于LeetCode --- 1221. Split a String in Balanced Strings 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

1221. Split a String in Balanced Strings

[JavaScript 刷题] 贪心 - 分割平衡字符串, leetcode 1221

leetcode1221

leetcode1221. 分割平衡字符串

leetcode简单1221分割平衡字符串

LeetCode 1221 分割平衡字符串[贪心] HERODING的LeetCode之路