Failed test case 2

You are not taking into account that adding a *(an extra character) in the given string would increase it’s size.

Running your code for:
hellloool

expected output:
hellloool

Actual Output:
helllo*ool

Solution: Pass n+1 as size in the recursive function call if condition satisfies

else{
if(str[s]==prev){
str.insert(s,"*");
display(str,str[s],n+1,s+1);
}
else
display(str,str[s],n,s+1);
}

Hope, this would help.
if you still have doubts, feel free to ask.
Give a like if you are satisfied.:wink: