The TransCompilator

Solved LeetCode program · 889 of 1,000

#1221 · Split a String in Balanced Strings

Easy String chunk-18.md

Original English source

The symbols is "RLRRLLRLRL". The balance is 0. The pieces is 0.
For every spot from 0 to the last position of symbols.
The symbol is character spot of symbols. If symbol is "R", add 1 to balance, otherwise subtract 1 from balance. If balance is 0, add 1 to pieces.

Show pieces.

Open in Playground Browse all 1,000 problems

Expected stdout

4