[algogeeks] Find Max Sum Value Pairs

2011-09-01 Thread Navneet Gupta
Given two sorted positive integer arrays A(n) and B(n), we define a set S = {(a,b) | a in A and b in B}. Obviously there are n2 elements in S. The value of such a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs from S with largest values. need an O(n) algorithm. -- Regards,

Re: [algogeeks] Find Max Sum Value Pairs

2011-09-01 Thread bharatkumar bagana
@Mac: It gives us the first largest pair but need not all n pairs .. ex: A=1 1 3 4 B=1 2 3 4 pairs : (4,4),(4,3),(3,3),(2,4) . On Thu, Sep 1, 2011 at 4:57 AM, MAC macatad...@gmail.com wrote: since its sorted , cant we just take last (largest if assedning) elements of each and return o(1)

Re: [algogeeks] Find Max Sum Value Pairs

2011-09-01 Thread rajul jain
@bharat I think pair of your example would be (4,4) , (4,3) ,(3,4), (3,3) correct me if am wrong.. On Thu, Sep 1, 2011 at 4:55 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @Mac: It gives us the first largest pair but need not all n pairs .. ex: A=1 1 3 4 B=1 2 3 4 pairs