Given an encoded string in form of "ab[cd]{2}def"
You have to return decoded string "abcdcddef"
Notice that if there is a number inside curly braces, then it means preceding string in square brackets has to be repeated the same number of times. It becomes tricky where you have nested braces.
Example 1:
Input: "ab[cd]{2}"
Output: "abcdcd"Example 2:
Input: "def[ab[cd]{2}]{3}ghi"
Output: "defabcdcdabcdcdabcdcdghi"Similar problems: