char *remdup(char *str)
{
int max_string_length=300; //assume max length is 300 charecters
char heapchr[max_string_length]={0};
int input=0;
int output=0;
char tp;
while(*(str+input)!='\0')
{tp=*(str+input);
if(heapchr[tp]==0)
{
heapchr[tp]=1;
*(str+ouput)=*(str+input);
output++;
}
input++;
}
*(str+output)='\0';
return str;
}
}
time = O(n)
On May 28, 11:02 am, Rajeev Kumar <[email protected]> wrote:
> Design an algorithm and write code to remove the duplicate characters in a
> string without using any additional buffer.
> NOTE: One or two additional variables are fine.
> An extra copy of the array is not.
>
> --
> Thank You
> Rajeev Kumar
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.