**k Sum II**

Given n unique integers, number k (1<=k<=n) and target. Find all possible k integers where their sum is target.

**Example**

Given [1,2,3,4], k=2, target=5, [1,4] and [2,3] are possible solutions

Solutions: DFS

Time Complexity?

public ArrayList < ArrayList < Integer >> kSumII(int A[], int k, int target) { ArrayList < ArrayList < Integer >> result = new ArrayList < > (); if (A == null) { return result; } kSumIIHelper(new ArrayList < Integer > (), 0, A, k, target, result); return result; } public void kSumIIHelper(ArrayList < Integer > curr, int index, int A[], int k, int target, ArrayList < ArrayList < Integer >> result) { if (curr.size() == k) { if (target == 0) { result.add(new ArrayList < > (curr)); } return; } for (int i = index; i < A.length; i++) { curr.add(A[i]); kSumIIHelper(curr, i + 1, A, k, target - A[i], result); curr.remove(curr.size() - 1); } }