On Sep 8, 10:47 am, yash <yashpal.j...@gmail.com> wrote:
> wap a program in efficient manner to remove all occurrence of
> duplicate character in the word and all occurrence of duplicate word
> in the file.
>
> i break the problem in two section( this is my approach it may be
> better one )
>
> wap to remove all duplicate character in the word. (order is important)
> [i don't know which DS we use for this program your suggestion has
> highly appreciated]
> wap to remove all duplicate word in the file. (order is important)[we
> use tries to remove all duplicate word in the file]
>
> input in file
>
> we welcome your feedback, suggestions comment to make better your
> world
>
> After run the above compression algo output will be
>
> we welcom your fedback, sugtion coment to make betr world
>
> --
> Kind Regards
>   ^_^
> Yashpal Jain
> Software Developer-IDC Risk
> PayPal - an ebay company

For the first Problem:

int alph[26];

void RemDuplicate(char buf[])
{
 size_t i = 0,t;
 while(buf[i]){
        alph[buf[i] - 97] = 1;
        i++;
 }

 for(t = 0,i = 0;i < 26;i++)
         if(alph[i])
            buf[t++] = i + 97;

        buf[t] = 0;
}

I have assumed that the inputs consists of lower case letters.Any
uppercase letter input will invoke UB, but it can be avoided by a
little bit modification.The module program for the above
algorithm :http://codepad.org/vTeVxKPZ

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to