Skip to content

Latest commit

 

History

History

two-sum

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Two sum

Description

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.

Implementation

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] ]