Nested String Decompression

Asked at GoogleOnsite

Reported by the problem's creator, not verified

A compressed string is built from lowercase letters and groups written (text){k}. A group stands for text repeated k times, and text may itself contain more groups.

Examples

  1. Example 1

    Input: s = a(abc){3}

    Output: aabcabcabc

    Explanation: The group (abc) repeats three times after the leading a.

  2. Example 2

    Input: s = a(b(c){2}){3}d

    Output: abccbccbccd

    Explanation: The inner group (c){2} makes cc, so the outer group expands to bcc repeated three times between a and d.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.