A barcode label printer receives text in a compact form: a count followed by one character, repeated. 3a2b means aaabb. Counts can have several digits, so 12x means twelve x characters.
Write expandLabel(code) that returns the full text. Every character in the output is a non-digit, and each one is preceded by its count. An empty code gives an empty string.
Input: code = "3a2b" Output: "aaabb"
Three a, then two b.
Input: code = "12x1y" Output: "xxxxxxxxxxxxy"
The count 12 has two digits.
0 <= code.length <= 10001 and 1000.10^5 characters.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #623 Expand a Compressed Label. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.