Created
February 13, 2020 20:56
-
-
Save Mk-Etlinger/0dc96edcbb9f17974b3b583982f23248 to your computer and use it in GitHub Desktop.
Hacker Rank pairSum challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pairSum(data, target) { | |
const pairMatches = {}; | |
for(let i = 0; i < data.length; i++) { | |
const number = data[i]; | |
const difference = (target - number); | |
if (pairMatches[number]) { | |
return true; | |
} | |
pairMatches[difference] = difference; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment