Run-Length Decode
s is made of pairs: a lowercase letter followed by a count written as one or more digits. Expand each pair into that letter repeated count times, and return the whole string. An empty s gives an empty string.
Example 1
s "a3b1c2"
returns "aaabcc"
aaa + b + cc.
Example 2
s "x12"
returns "xxxxxxxxxxxx"
The count may have several digits.
Constraints
0 <= len(s) <= 100- Every count is between 0 and 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Split Camel CaseEasy
- String CompressionEasy
- Subtract Digit StringsEasy
- Valid Calendar DateEasy
- Valid UsernameEasy
- Well-Formed SumEasy
- Add the FractionsMedium
- Count and SayMedium