Function checks the all possible combinations, and returns the count of possible combination in exponential Time Complexity. >>> combination_sum_iv([1,2,5], 5) 9
(array: list[int], target: int)
| 24 | |
| 25 | |
| 26 | def combination_sum_iv(array: list[int], target: int) -> int: |
| 27 | """ |
| 28 | Function checks the all possible combinations, and returns the count |
| 29 | of possible combination in exponential Time Complexity. |
| 30 | |
| 31 | >>> combination_sum_iv([1,2,5], 5) |
| 32 | 9 |
| 33 | """ |
| 34 | |
| 35 | def count_of_possible_combinations(target: int) -> int: |
| 36 | if target < 0: |
| 37 | return 0 |
| 38 | if target == 0: |
| 39 | return 1 |
| 40 | return sum(count_of_possible_combinations(target - item) for item in array) |
| 41 | |
| 42 | return count_of_possible_combinations(target) |
| 43 | |
| 44 | |
| 45 | def combination_sum_iv_dp_array(array: list[int], target: int) -> int: |
no test coverage detected