Saturday, July 9, 2011
Given two sorted positive integer rrays A(n) and B(n). We define a set S = {(a,b) such that a in A and b in B}. Obviously there are n^2 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. The tricky part is that we need an O(n) algorithm.
Labels:Data
Google Interview
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment