377. Combination Sum IV

Practice Combination Sum IV for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Given distinct positive integers nums, count the ordered sequences of numbers from nums (each number may repeat) that add up to target. Different orders count as different sequences.

Example

nums = [1,2,3], target = 4  ->  7
  (1,1,1,1) (1,1,2) (1,2,1) (2,1,1) (1,3) (3,1) (2,2)
nums = [9], target = 3      ->  0

Constraints