Back to problems

Combination Sum IV

Algorithm · Medium

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: Explanation: The sequences that reach the sum 7 are (2, 2, 3), (2, 3, 2), and (3, 2, 2).…

Checking your access…