stack for sure.. pop out the enteries till they r same and push this entry back once.
On Wed, Feb 16, 2011 at 11:18 AM, jalaj jaiswal <jalaj.jaiswa...@gmail.com>wrote: > can any1 tell me the question .. m gettin half of the post ,... > > On Wed, Feb 16, 2011 at 10:41 AM, Jammy <xujiayiy...@gmail.com> wrote: > >> @Abhijit. Does your code takes O(N^2)? I think the following code >> would do it in O(N) >> >> iterate the string once: >> >> void remove(char *a){ >> if(!a){ >> int i = 0, j = 1; >> while(a[j]!='\0'){ >> if(i<0 || a[i]!=a[j]){ >> if(j-1>i){ >> a[i+1] = a[j]; >> } >> i++;j++; >> }else{ >> for(;a[j]==a[i];j++); >> i--; >> } >> } >> a[i+1] = '\0'; >> } >> } >> >> On Feb 14, 11:17 pm, Tushar Bindal <tushicom...@gmail.com> wrote: >> > if we have "RBGGGBGGBR" >> > what should be the answer??? >> > "RBGR" or ""(empty string) >> > >> > On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami < >> rajan.goswam...@gmail.com>wrote: >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > > yeh. >> > > Agree with ramkumar. >> > > Simplest solution is to use Stack... >> > >> > > On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao < >> abhijitkrao...@gmail.com>wrote: >> > >> > >> I could not get it for recursively, but iteratively, I coded a >> solution. >> > >> If anyone knows recursively, >> > >> let us know please. >> > >> > >> #include<stdio.h> >> > >> void main() >> > >> { >> > >> char s[18]="DGGDBCBHH"; >> > >> int i=0,j=0; >> > >> int count; >> > >> while(s[i]!='\0') >> > >> { >> > >> if(s[i] == s[i+1]) >> > >> { >> > >> count = strlen(s)-2; >> > >> while(count--) >> > >> { >> > >> s[i]=s[i + 2]; >> > >> i++; >> > >> } >> > >> s[i]='\0'; >> > >> i=0; >> > >> } >> > >> else >> > >> { >> > >> i++; >> > >> } >> > >> } >> > >> printf("%s",s); >> > >> getch(); >> > >> } >> > >> > >> I/P: DGGDBCBHH O/P: BCB >> > >> > >> Best Regards >> > >> Abhijit >> > >> > >> On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam < >> > >> ramkumars....@gmail.com> wrote: >> > >> > >>> use stack. >> > >> > >>> -- >> > >>> 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. >> > >> > > -- >> > > 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. >> > >> > -- >> > Tushar Bindal >> > Computer Engineering >> > Delhi College of Engineering >> > Mob: +919818442705 >> > E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com >> >> -- >> 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. >> >> > > > -- > With Regards, > *Jalaj Jaiswal* (+919019947895) > Software developer, Cisco Systems > B.Tech IIIT ALLAHABAD > > -- > 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.