Compress the String

Write a program to do basic string compression. For a character which is repeated more than once, replace consecutive duplicate occurrences with the count of repetitions e.g. if a String has 'x' repeated 5 times, replace this "xxxxx" with "x5".

Note : You don't need to print the changed string.

Sample Input:
Sample Output:

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem