Tomaz Kastrun knows if you can sum those together:
CanSum problem is a problem where a given array of integers (
nums) and a target integer (
target), return boolean (TRUE \ FALSE) indicating, that the
integer can be calculated using two or more numbers in array
You may assume that each integer from the array can be used multiple times. You can also assume, that any integer (in
target) is from 0 to +1e9 and the length of the
numsarray is from 2 to 1000 elements.
Click through for an example of one brute-force solution, followed by a much faster solution.