Find Combination Sum
Let's join the exciting world of numbers with a fun challenge! Your task is to find if it's possible to pick some numbers from a list of positive integers such that they sum up to exactly a given number.
For this challenge, your mission is to implement a function named find_combination_sum that takes in a list of positive integers and an integer target. The function should return True if there is a combination of numbers in the list that sums up to the target; otherwise, it should return False.
Example:
-
If you have a list
[2, 3, 7, 1]and the target is6, you can choose numbers like3and3, or2,2, and2to sum up to6. So the function should returnTrue.find_combination_sum([2, 3, 7, 1], 6) # Output: True -
With the list
[2, 4]and the target5, no combination can sum up to5.find_combination_sum([2, 4], 5) # Output: False -
For list
[5]and target5, you can pick5itself to match the target.find_combination_sum([5], 5) # Output: True
Are you ready to test your skills and logical reasoning? Happy coding!
Inputs
Arg 1:
[2,3,7,1]Arg 2:
6Expected Output
trueActual Output