On Sat, May 28, 2011 at 11:32 AM, Rajeev Kumar <rajeevprasa...@gmail.com> 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 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?hl=en. >
I have a solution. Please check whether is fits the requirement: #include<unistd.h> #include<stdio.h> #include<stdlib.h> int main() { char input[256], ele; int i, j, size; printf("Enter input string::"); scanf("%s",input); size = strlen(input); for(i = 0; i< size; i++) { if(input[i]) ele = input[i]; else continue; for(j=i+1; j < size; j++) { input[j] ^= ele; if(input[j]) { input[j] ^= ele; } } } for(i=0; i < size;i++) printf("%c",input[i]); } -- Dinesh Bansal The Law of Win says, "Let's not do it your way or my way; let's do it the best way." -- 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?hl=en.