Back to problems

String Decompression with Nested Counts

Algorithm · Google · Medium

Requirements Input: a string following the pattern ( ){k} ..., with these rules: Parentheses enclose a segment that can be duplicated, and the {k} directly after its closing parenthesis specifies how many copies to produce. A repeated segment can contain further repeated segments at any depth. Characters that are not inside a group are included unchanged. k is an integer from 2 through 99, inclusive. Output: return the completely expanded string. You may treat the input as…

Checking your access…