Start with pair (A(i), B(j)) where i and j are both n.
Then the next largest pair will either be (A(i-1), B(n)) or (A(n),
B(j-1)). Whichever sum is larger, set i and j to those values. Repeat
as desired.

Don

On Sep 1, 3:45 am, Navneet Gupta <navneetn...@gmail.com> wrote:
> 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,
> Navneet

-- 
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.

Reply via email to