diff --git a/arrays/find-pair/second-approach.js b/arrays/find-pair/second-approach.js new file mode 100644 index 0000000..ad105ce --- /dev/null +++ b/arrays/find-pair/second-approach.js @@ -0,0 +1,16 @@ +let findSumOfTwo = function (nums, val) { + let set = new Set(); + + for (let item of nums) { + console.log(item); + if (set.has(val - item)) { + return true; + } + + set.add(item); + } + + return false; +}; + +console.log(findSumOfTwo([2, 1, 8, 4, 7, 3], 3));