Expand Repeated Runs
After run-length encoding, you need to be able to rebuild the original string: each number tells how many times to repeat the next character. The function rle_decode receives an encoded string like 3a2b1c and expands it back to the original form. Repetition counts may have multiple digits, so read each full number before repeating the character.
Примеры
Ввод
"3a2b1c"Вывод
"aaabbc"Ввод
"5a"Вывод
"aaaaa"Ввод
"1a1b1c"Вывод
"abc"Нужно реализовать
def rle_decode(s: str) -> str:
Теги
strings
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänVisible tests
1
Input
"3a2b1c"Expected
"aaabbc"2
Input
"5a"Expected
"aaaaa"3
Input
"1a1b1c"Expected
"abc"4
Input
""Expected
""5
Input
"12W1B12W3B"Expected
"WWWWWWWWWWWWBWWWWWWWWWWWWBBB"6
Input
"10x"Expected
"xxxxxxxxxx"Focus radio
Paused · SomaFM · Fluid