我终于明白了# pets - 心有所宠
A*r
1 楼
you are given 2 arrays sorted in decreasing order of size m and n
respectively.
Input: a number k <= n*m and >= 1
Output: the kth largest sum(a+b) possible. where
a (any element from array 1)
b (any element from array 2)
如果直接一个一个算的话,从大到小,需要O(k)复杂度。
不知道最优解是多少,是O(logk) 还是O(1) ?
在careercup上看到的,有人提出来了最优解是O(1), 但是觉得不太对头。。
respectively.
Input: a number k <= n*m and >= 1
Output: the kth largest sum(a+b) possible. where
a (any element from array 1)
b (any element from array 2)
如果直接一个一个算的话,从大到小,需要O(k)复杂度。
不知道最优解是多少,是O(logk) 还是O(1) ?
在careercup上看到的,有人提出来了最优解是O(1), 但是觉得不太对头。。