Unique Combinations
ARRAY
BACKTRACKING
Problem
Given an array of distinct integers called numbers
and an integer target
, your task is to return how many unique combinations from numbers
that sum up to target
.
Each number in numbers
can be used an unlimited number of times in the combinations.
Combinations are considered unique if they differ in frequency for at least one of the numbers used.
Examples
findCombinations([2,3], 8) // return 2 // Why? Unique combinations are: [2,2,2,2] and [2,3,3] findCombinations([2,5,8], 12) // return 3 /* Why? Unique combinations are: [2,2,2,2,2,2], [2,2,8], [2,5,5] */
Loading...
Loading...Loading...