Solved LeetCode program · 889 of 1,000
#1221 · Split a String in Balanced Strings
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.
Expected stdout
4