Skip to content

Instantly share code, notes, and snippets.

@Mk-Etlinger
Created February 13, 2020 20:56
Show Gist options
  • Save Mk-Etlinger/0dc96edcbb9f17974b3b583982f23248 to your computer and use it in GitHub Desktop.
Save Mk-Etlinger/0dc96edcbb9f17974b3b583982f23248 to your computer and use it in GitHub Desktop.
Hacker Rank pairSum challenge
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