why have you divided it into three . I mean it can be divided into many groups of consecutive . Please write the statement properly !
On Jan 30, 11:13 am, snehal jain <learner....@gmail.com> wrote: > @nishanth > divide into groups ( not necessarily 2) in as many group as possible.. such > that elements in each group is consecutive > > another example to clearify > > A= { 9,7, 13, 11,6,12,8,10,3, 4, 2, 16,14,17,13,15) > ans > <9,7,13,11,6,12,8,10> > <3,4,2> > <16,14,17,13,15> > > > > On Sun, Jan 30, 2011 at 11:32 AM, nishaanth <nishaant...@gmail.com> wrote: > > @snehal..i guess you are missing something in the question...divide it into > > 2 groups such that (there should be some other condition or criterion)..... > > > On Sun, Jan 30, 2011 at 11:29 AM, snehal jain <learner....@gmail.com>wrote: > > >> my approach > > >> sort in nlogn and then while traversing the array put the elements in a > >> group till they are consecutive . when a[i+1]!=a[i]+1 then put a[i+1] in > >> different group.. now we need to rearrange elements in the group so that > >> they are according to the given array.. but that will make it O(n^2) .. > >> anyone with better ideas? > > >> On Fri, Jan 21, 2011 at 1:20 PM, snehal jain <learner....@gmail.com>wrote: > > >>> Divide a list of numbers into groups of consecutive numbers but their > >>> original order should be preserved. > >>> Example: > >>> <8,2,4,7,1,0,3,6> > >>> Two groups: > >>> <2,4,1,0,3> <8,7,6> > >>> Better than O(n^2) is expected. > > >>> -- > >>> 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<algogeeks%2Bunsubscribe@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<algogeeks%2Bunsubscribe@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<algogeeks%2Bunsubscribe@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.