Practice Split a String in Balanced Strings
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Balanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it into some number of substrings such that: Return the maximum number of balanced strings you can obtain.
Source: Split a String in Balanced Strings on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "RLRRLLRLRL"
Output
4
# Example 2
Input
s = "RLRRRLLRLL"
Output
2
# Example 3
Input
s = "LLLLRRRR"
Output
1
Constraints
2 <= s.length <= 1000
s[i] is either 'L' or 'R'.
s is a balanced string.
Related LeetCode Problems
Practice more problems similar to Split a String in Balanced Strings.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.