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