package leetcode;

/**
 * https://leetcode.com/problems/combination-sum-iv/
 */
public class Problem377 {
    public int combinationSum4(int[] nums, int target) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem377 prob = new Problem377();
        System.out.println(prob.combinationSum4(new int[]{1, 2, 3}, 4)); // 7
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -217,32 +217,559 @@
     
-// TODO%0A        return 0
+return combinationSum(nums, target, new HashMap%3C%3E());%0A    %7D%0A%0A    private int combinationSum(int%5B%5D nums, int target, Map%3CInteger, Integer%3E memo) %7B%0A        if (target %3C 0) %7B%0A            return 0;%0A        %7D%0A        if (target == 0) %7B%0A            return 1;%0A        %7D%0A        if (memo.containsKey(target)) %7B%0A            return memo.get(target);%0A        %7D%0A        int count = 0;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            count += combinationSum(nums, target - nums%5Bi%5D, memo);%0A        %7D%0A        memo.put(target, count);%0A        return count
 ;%0A  

Solve problem 377