Given a string, compute recursively a new string where identical chars that are adjacent in the original string are separated from each other by a "*".
Sample Input 1: "hello"
Sample Output 1: "hel*lo"
Sample Input 2: "xxyy"
Sample Output 2: "x*xy*y"
Sample Input 3: "aaaa"
Sample Output 3: "a*a*a*a"
Explanation:
In this question, we have to add a star between any pair of same letters. This could be easily achieved using recursion. When the start index is equal to (start + 1) index, we will shift all the letters from (start + 1) by 1 on the right side and on (start + 1), we will add a star.
Algorithm:
Shift all the letters from start+1 to right side by 1.
Example:
C++ program:
Output