public void dfs(int nums[],ArrayList<Integer> path, int k, int begin, int target) {
        // base class
        if (k == 1) {
            for (int i = begin; i < nums.length; ++i) {
                if (nums[i] == target) {
                    ArrayList<Integer> temp = new ArrayList<Integer>(path);
                    temp.add(nums[i]);
                    ans.add(new ArrayList<Integer>(temp));
                }
            }
            return;
        }
        for (int i = begin; i <= nums.length - k; ++i) {
            int val = nums[i];
            if (val >= target)
                return;
            path.add(val);
            dfs(nums, path, k - 1, i + 1, target - val);
            path.remove(path.size() - 1);
        }
    }