Re: [algogeeks] interview quest..
if we have "RBGGGBGGBR" what should be the answer??? "RBGR" or ""(empty string) On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami wrote: > yeh. > Agree with ramkumar. > Simplest solution is to use Stack... > > > On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao wrote: > >> I could not get it for recursively, but iteratively, I coded a solution. >> If anyone knows recursively, >> let us know please. >> >> #include >> 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.
Re: [algogeeks] interview quest..
yeh. Agree with ramkumar. Simplest solution is to use Stack... On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao wrote: > I could not get it for recursively, but iteratively, I coded a solution. If > anyone knows recursively, > let us know please. > > #include > 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.
Re: [algogeeks] interview quest..
I could not get it for recursively, but iteratively, I coded a solution. If anyone knows recursively, let us know please. #include 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 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.
Re: [algogeeks] interview quest..
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.
[algogeeks] interview quest..
can anyone help..? Suppose we have a string "RGBBGBGR". we have to eliminate the couple (two same chars adjacent to each other) recursively. For example RGBBGBGR --> RGGBGR-->RBGR -- balaji ;-) -- 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.