You will be given an array and a target sum and your goal is to find all pairs in the given array that add up to the target sum.
twoSum(numArray, sum)
should return every pair of numbers from numArray
that adds up to the sum
.
There are some conditions:
- result should be an array of arrays.
- any number in the
numArray
can be used in multiple pairs.
For example:
twoSum([1, 6, 4, 5, 3, 3], 7) // [ [6, 1], [3, 4], [3, 4] ]