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]]
思路:
与求组合思路类似,只是将增加的限制条件加进去就好。
代码:
网友评论