Combination Sum IV
Backpack VI (LI.564)
Given an integer array sizes with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
Example
I: sizes = [1,2,4], target = 4
O: [ [1,1,1,1], [1,1,2], [1,2,1], [2,1,1], [2,2], [4] ] = 6State Graph

Code
Better Code
Combination Sum IV (LC.377)
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
Example
Analysis
Combination sum as the name suggests, we want combinations. This is a full knapsack problem.
Approach
Code
Better Code
Time & Space Complexity
Time: O(n*target) Space: O(target)
Last updated