How to remove all adjacent duplicates in a string in C. say for example..if "caaabbcdd" is the given string then it should remove sequentially as
1. cbbcdd
2. ccdd
3. dd
thus an empty string is returned in the end. Time complexity can be O(n^2) for starting.Can anyone help.
so far this i what i have done
void recursiven2(char *str)
{
int i,j,k,len;
len=strlen(str);
for(i=0;i<len-1;i++)
{
if(str[i]==str[i+1])
{
for(j=i;j<len-2;j++)
str[j]=str[j+2];
str[j]='';
}
}
}
See Question&Answers more detail:os