Split a String in Balanced Strings Problem

Split a String in Balanced Strings Problem — ExecCode Easy DSA Practice

Solve the Split a String in Balanced Strings problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a balanced string s, split it into some number of substrings such that:. Your task is to compute the required answer and return the maximum number of balanced strings you can obtain. Balanced strings are those that have an equal quantity of 'L' and 'R' characters. - Each substring is balanced.

Examples

Input {"s": "RLRRLLRLRL"}; Output 4. Input {"s": "RLRRRLLRLL"}; Output 2

Constraints

2 <= s.length <= 1000 s[i] is either 'L' or 'R'. s is a balanced string.

Practice Split a String in Balanced Strings free on ExecCode. Browse DSA problems, topic map, and placement guides.