Array Pair Sum
This is the first post on a series where I will be resolving some common coding interview questions.
The question
Given an integer array, output all pairs that sum up to a specific value k.
My solution
I like to start by creating a test for my solution:
1
2
3
var arr = [1, 4, 2, 6, 8, 3, 9, 0, 7];
var res = findPairs(arr, 7);
// I expect res to be [[1, 6], [4, 3], [0, 7]]