登录
  • #刷题
  • #数组

two sorted lists fetch k largest sum

章鱼小丸子
1321
6
题目:

Given 2 sorted lists of numbers M and N, find the k highest values of M(i) + N(j) in O(k)

举个例子来说,如果两个list 分别是

[20 15 13 7 2]

[8 7 3 1]

求最大的 9 个sum就是

28= 20+8

27 = 20+7

23 = 20+3

23 = 15+ 8

22 = 15 +7

21 = 20+1

21 = 13 +8

20 = 13 +7

18 = 15 + 3

跪求指导~~谢谢~
6条回复
热度排序

发表回复