Decompress the String
EasyP3Coding
s is a run-length encoded string: a sequence of groups, each made of one lowercase letter followed by a positive count written in decimal digits (one or more). Expand it and return the result. For a3b2 the result is aaabb.
Example 1
- Input
- s = "a3b2"
- Output
- "aaabb"
Example 2
- Input
- s = "a1"
- Output
- "a"
Example 3
- Input
- s = "z9"
- Output
- "zzzzzzzzz"
Constraints
- 0 <= s.length <= 1000
- Each group is a letter followed by a count between 1 and 100.
- The expanded string has at most 10^5 characters.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.