Given an array nums of unique positive integers and a positive integer target, return the number of ordered sequences of elements from nums that sum exactly to target. Each element may be used as many times as needed.
Sequences are counted separately when they contain the same values in a different order. The test data guarantees the result fits in a 32-bit signed integer.
Example 1:
Input: nums = [2,3], target = 7
Output: 3
Explanation: The sequences that reach the sum 7 are (2, 2, 3), (2, 3, 2), and (3, 2, 2).
nums = [2,3] target = 7
3
We are given the numbers [2, 3] and a target sum of 7. We need to find all ordered sequences of these numbers that sum to 7.
Example 2:
Input: nums = [1,4], target = 5
Output: 3
Explanation: The sequences are (1, 1, 1, 1, 1), (1, 4), and (4, 1).
Example 3:
Input: nums = [5], target = 3
Output: 0
Constraints:
1 <= nums.length <= 2001 <= nums[i] <= 1000nums are distinct.1 <= target <= 1000Follow‑up: If nums were allowed to contain negative numbers, how would the problem change, and what extra restriction would guarantee the answer remains finite?
nums = [2,3] target = 7
3
We are given the numbers [2, 3] and a target sum of 7. We need to find all ordered sequences of these numbers that sum to 7.