The DP solution goes through every possible sum from 1 to target one by one.

Using recursion can skip those sums that are not the combinations of the numbers in the given array. Also, there is no need to sort the array first.

```
public class Solution {
Map<Integer, Integer> map = new HashMap<>();
public int combinationSum4(int[] nums, int target) {
int count = 0;
if (nums == null || nums.length ==0 || target < 0 ) return 0;
if ( target ==0 ) return 1;
if (map.containsKey(target)) return map.get(target);
for (int num: nums){
count += combinationSum4(nums, target-num);
}
map.put(target, count);
return count;
}
}
```