173. uncompress string

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.

What is time & space complexity of your approach?