Problem
Given an array of distinct positive integers nums and a target, return how many ordered sequences of numbers from nums add up to target. Numbers may be used any number of times, and different orders count as different sequences.
Example 1
- Input
- nums = [1, 2, 3], target = 4
- Output
- 7
Example 2
(1,1,1,1) (1,1,2) (1,2,1) (2,1,1) (2,2) (1,3) (3,1)
Example 3
- Input
- nums = [9], target = 3
- Output
- 0
Constraints
1 <= nums.length <= 2001 <= nums[i] <= 10001 <= target <= 1000The answer fits in a 32-bit integer.