90. k Sum II

2019-06-27  本文已影响0人  鸭蛋蛋_8441

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

思路:

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

代码:

上一篇下一篇

猜你喜欢

热点阅读