Balanced Letter Cuts
A balanced part of a string contains the same number of L and R characters. Write a function balanced_string_split that receives a string made only of these two characters. Split it into the maximum possible number of balanced substrings. Return that count.
Примеры
Ввод
"RLRRLLRLRL"Вывод
4Ввод
"RLRRRLLRLL"Вывод
2Ввод
"LLLLRRRR"Вывод
1Нужно реализовать
def balanced_string_split(s: str) -> int:
Теги
stringsstack
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
"RLRRLLRLRL"Expected
42
Input
"RLRRRLLRLL"Expected
23
Input
"LLLLRRRR"Expected
14
Input
"RLRRLL"Expected
25
Input
"LR"Expected
16
Input
"RL"Expected
1Focus radio
Paused · SomaFM · Fluid