You’re given a function –

char *CompressString(char* str);

The function accepts a string as an argument that may contain repetitive characters. Implement the function to modify and return the input string, such that each character once, along with the count of consecutive occurrence. Do not append count if the character occurs only once.

Note – 

  • The string will only contain lowercase English Alphabets
  • If you have to manipulate the input string in place you cant use another string

Assumption – 

No character will occur consecutively more than 9 times.

Example – 

input – aaaaabbbccccccccdaa

OutPut – a4b3c8da2


Please write the code in the comments in all languages it will be added here later –