Loading...
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.
Input: values = [2,3,5], target = 9
Output: 3
Explanation: The combinations are {2,2,5}, {3,3,3} and {2,2,2,3}.
Input: values = [2,3,5], target = 1
Output: 0
Explanation: Every value exceeds 1, so no combination sums to 1.
values.length ≤100target ≤104values[i] ≤104Click "Run" to test with sample cases or "Submit" to run all tests.