美文网首页
90. k Sum II

90. k Sum II

作者: 鸭蛋蛋_8441 | 来源:发表于2019-06-27 07:08 被阅读0次

Description

Given n unique postive integers, number k (1<=k<=n) and target.

Find all possible k integers where their sum is target.

Example

Example 1:

Input: [1,2,3,4], k = 2, target = 5

Output:  [[1,4],[2,3]]

Example 2:

Input: [1,3,4,6], k = 3, target = 8

Output:  [[1,3,4]]

思路:

与求组合思路类似,只是将增加的限制条件加进去就好。

代码:

相关文章

网友评论

      本文标题:90. k Sum II

      本文链接:https://www.haomeiwen.com/subject/henkcctx.html