For the first problem.

All occurrence of a duplicate character in a word.

void RemoveDuplicates(char *word) {
  int count[256] = {0, 0};
  char *p = word;

  while ( p ) {
    count[(int)(*p)] = 1;
    p++;
  }

  p = word;
  char *q = word;

  while ( q ) {
    if ( count[*q] ) {
      *p = *q;
       count[*q] = 0;
       p++;
       q++;
    }  else {
       q++;
    }
  }
  *p = '\0';
}


2009/9/8 Matic Potočnik <maticpotoc...@gmail.com>

>
> Hashing for words,
> and a mapping to ASCII values for characters (make array of size
> 256... if (A[(int)string[i]] == 0), an original char, A[(int)string[i]]
> ++, else a duplicate char)
>
> Go through string and delete duplicate chars and when you reach the
> end of a word hash it and add it to output if it's original.
>
> On Sep 8, 7: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
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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