You are given an array values of distinct positive integers and a positive integer target.
Count the multisets of values that sum to exactly target. Each value may appear any number of times, and order does not matter: {2, 2, 5} and {2, 5, 2} are the same combination.
Return the count modulo 10^9 + 7.
Examples
Example 1
Input: values = [2,3,5], target = 9
Output: 3
Explanation: The combinations are {2,2,5}, {3,3,3} and {2,2,2,3}.
Example 2
Input: values = [2,3,5], target = 1
Output: 0
Explanation: Every value exceeds 1, so no combination sums to 1.
Constraints
1≤values.length≤100
1≤target≤104
1≤values[i]≤104
All values are distinct.
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up