After first iteration, adjacent similar characters are converted to get a single character After second iteration, similar adjacent strings of length 2 in the remaining string are replaced with single string of length 2 After third iteration, similar adjacent strings of length 3 in the remaining string are replaced with single string of length 3
Hope I have clarified On Dec 13, 10:26 am, atul anand <atul.87fri...@gmail.com> wrote: > well 1st part can be done of removing similar character , > for the 2nd iteration where you want to remove continuous duplicate sub > string then i guess this can be done :- > > for example :- > input : aabbabc > > 1st iteration : ababc > > for 2nd iteration consider queue > > 1) maintain front value inserted int the queue in a variable : > > now queue will have : ba : front = a > for i=3, front == str[i]; > start=i; > while ( dequeue() != NULL) > { > val=dequeue(); > if(val == str[i]) > { > i++; > } > > } > > if(isDequeueEmpty()) > { > //we know that from start to i is a repeated substr and should be > removed. > > > > } > On Mon, Dec 12, 2011 at 7:52 PM, top coder <topcode...@gmail.com> wrote: > > For example if aabbabc is given as input after first iteration, it > > should be ababc and after that it should become abc. if aabbcabc is > > given it should give abcabc after first interation, no change in > > second iteration and abc after third iteration. > > > -- > > 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.- Hide quoted text - > > - Show quoted text - -- 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.