173. uncompress string

JavaScriptstringalgorithm

medium  - accepted / - tried

Given a compressed string, return its original form.

For example.

uncompress('3(ab)') // 'ababab'
uncompress('3(ab2(c))') // 'abccabccabcc'
  1. a number k followed by a pair of parenthesis, meaning to repeat the substring inside the parenthesis by k times, k is positive integer.
  2. inputs are guaranteed to be valid input like above example, there is no numerical digit in original form.

Think about the edge cases.

(6)