- You are given a string.
- You have to compress the given string in the following two ways -
- First compression- The string should be compressed such that consecutive duplicates of characters are replaced with a single character.
- For "aaabbccdee", the compressed string will be "abcde".
- Second compression -> The string should be compressed such that consecutive duplicates of characters are replaced with the character and followed by the number of consecutive duplicates.
- For "aaabbccdee", the compressed string will be "a3b2c2de2".
Example 1:
Input: wwwwaaadexxxxxx Output: wadex w4a3dex6
Constraints:
1 <= length of string <= 1000