Re: [algogeeks] Re: Duplicates in a string
than we can make a make bit set for keep track. only require one bit per character. we can track 256 character by just 256/32 =8 integer . i think that is sufficient for c language. -- 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.
Re: [algogeeks] Re: Duplicates in a string
@hary : Ur solution is good... But if the problem is modified so that the string can contain alphanumeric characters is there any better way to do it.. On 5 August 2011 23:11, hary rathor wrote: > i have used 26 bit of checker variable > then i have checked in "if statemet " that if bit is set there then put > then character in jth posion, > then set the the bit for character > > -- > 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. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- 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.
Re: [algogeeks] Re: Duplicates in a string
i have used 26 bit of checker variable then i have checked in "if statemet " that if bit is set there then put then character in jth posion, then set the the bit for character -- 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.
Re: [algogeeks] Re: Duplicates in a string
when you encounter the letter for first time then simply increment array having index=(ASCII value-65) and put that in vector next time when you will encounter the same variable again then condition will fail hence no change in content of vector hence in the end simply print the vector -- 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.
Re: [algogeeks] Re: Duplicates in a string
Can You please explain this bit manipualtion On Fri, Aug 5, 2011 at 10:31 PM, hary rathor wrote: > #include > int main () > { > char str[]="hello world"; > int i,j=0,checker=0; > > for(i=0;i { > int val=str[i]-'a'; >if ((checker&(1checker|=(1< } > > str[j]='\0'; > > printf("%s",str); > return 0; > > } > > -- > 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. > -- 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.
Re: [algogeeks] Re: Duplicates in a string
int b[26]={0}; vectorc; for(i=0;a[i];i++) { if(!b[(a[i]-65)]) { b[(a[i]-65)]++; c.push_back(a[i]); } } for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Duplicates in a string
@all : Thanks a lot for the solutions! On Fri, Aug 5, 2011 at 10:31 PM, hary rathor wrote: > #include > int main () > { > char str[]="hello world"; > int i,j=0,checker=0; > > for(i=0;i { > int val=str[i]-'a'; >if ((checker&(1checker|=(1< } > > str[j]='\0'; > > printf("%s",str); > return 0; > > } > > -- > 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. > -- 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.
Re: [algogeeks] Re: Duplicates in a string
#include int main () { char str[]="hello world"; int i,j=0,checker=0; for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Duplicates in a string
@priya its some thing like this for(i=0;a[i]!='\0';i++) count['a[i]']++; so its O(n) only -- 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.
Re: [algogeeks] Re: Duplicates in a string
@deepikayour solution is not O(n) i guess... @Sachinthe question says compress the *same* string. By 'printing' i dont know what you mean On Fri, Aug 5, 2011 at 5:17 PM, deepikaanand wrote: > static int array[256]; > removedupli(char s[],int n) > { > array[s[0]]=1; > for(i=1;i { > if(array[s[i]]==0) > array[s[i]]=1; > else > { > for(pos=i;i s[pos]=s[pos+1]; > i--; > > -- > 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. > > -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- 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.