say the arrays are a 6,7,9 b 3,4,5 c 1,2,8
the merged array would be 1c 2c 3a 4b 5b 6a 7a 8c 9a 1c,2c cant be compared as they are from same array..next is 3a this implies 3-2 =1 is min distance P.S: you can merge these in O(m+n+p) [merge from bottom as they are already sorted] Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sat, Jun 18, 2011 at 12:24 AM, Dumanshu <[email protected]> wrote: > @Ashish: could u plz explain ur algo in detail. "walk over the merged > list to get adjacent min distance and different tags" this would be of > the order O(m*n) say we merge A1 A2 of size m and n respectively. > Also, now how do u go ahead with the 3rd array? didn't get ur > solution. > > Harshal's solution looks fine. ny bugs? > > On Jun 17, 9:13 pm, Ashish Goel <[email protected]> wrote: > > merge two and if required third array keeping array tag with the > elements > > walk over the merged list and see adjacent distance which is minimum with > > the condition that the tage of the adjacent elements are different > > > > Best Regards > > Ashish Goel > > "Think positive and find fuel in failure" > > +919985813081 > > +919966006652 > > > > > > > > On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu <[email protected]> wrote: > > > U have got 3 sorted arrays A1 A2 and A3 having m n and p elements > > > respectively. A gap of 3 arrays is defined to be max distance between > > > 3 nos if they are put on a no line say u pick three 2 12 and 7 then > > > the gap is 10. Now u have to find an efficient way of chosing 3 nos > > > from these 3 seperate arrays (A1, A2, A3) such that their gap is > > > minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!! > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
