Adding Lists of Integers

You are given an array of integers and a single integer K as arguments. Return true if any combination of the integers found in the array will add up to K, false if not.

Requirements

  • Must return either true or false
  • Must also work with negative integers

Example #1

solve([17,2,1,4,3,15], 7)
> true

The integers 2, 1 and 4, as well as 4 and 3 add up to 7, so we return true

Example #2

solve([10,14,8,1], 6)
> false

No combination of integers from the array will add up to 6.

Example #3

solve([-10,14,12,-2], 2)
> true

-10, 14 and -2 add up to 2, so we return true.