You are the encoded form of a data string as follows: consecutive
occurrences of a letter (up to 9) are represented by the letter
followed by the number of occurrences.
For example, the string
stands for the string
- that is, 12 consecutive occurrences of a, followed by 2 bs, and then
4 cs, followed by a d and finally c
Given an encoded form, you have to output the data string.
The encoded form of the string, made as per the following rules.
- If a character occurs only once, then in the encoded string, it
appears as such (for example, ‘d’ in the above string.)
- If the number of consecutive occurrences of the character is
between 2 and 9, then it is represented as the character followed
by the number of occurrences (e.g. aaaab is represented as a4b).
- If the number of consecutive occurrences of a character is greater
than 9, then group 9 occurrences as per rule 2. Iterate the set of
rules on the remaining string.
The original string, consisting only of characters whose
encoding was given as input.