Algorithm to determine which numbers in a list are the sum of a given number
问题 I have a coding question that I am try to solve. I haven't been able to come up with a good algorithm yet. Given a number X (e.g. 200), determine which numbers from a list (e.g.: 4,5,10, 10, 23,67,889, 150, 50) will when summed up will be equal to X. In this case the answer is (50, 150). So far I thought about first sorting the the list (lowest to highest) then loop through adding the numbers until I get to a value greater than X. Discard all the remaining numbers in the list since they are