229. Combination Sum IV
MediumDynamic Programming
Given an array of **distinct** integers `nums` and a target integer `target`, return the number of possible combinations that add up to `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Note:** Different sequences are counted as different combinations (i.e., order matters).
Examples
Input: [1,2,3] 4
Output: 7
Explanation: The 7 ordered sequences: (1,1,1,1),(1,1,2),(1,2,1),(2,1,1),(2,2),(1,3),(3,1).
Constraints
- 1 <= nums.length <= 200
- 1 <= nums[i] <= 1000
- All the elements of nums are unique.
- 1 <= target <= 1000
Loading...
Run checks all cases above. Submit evaluates all test cases.