Skip to content

Instantly share code, notes, and snippets.

@antonybudianto
Created December 10, 2016 13:35
Show Gist options
  • Save antonybudianto/96502115cec6ff2b715c86f62ae36c9c to your computer and use it in GitHub Desktop.
Save antonybudianto/96502115cec6ff2b715c86f62ae36c9c to your computer and use it in GitHub Desktop.
pair of sum
function hasPairOfSum(arr, sum){
var flag;
for(let i=0;i<arr.length;i++) {
if (flag === arr[i]) { return true; }
else if (arr[i] !== sum/2) { continue; }
else if(!flag) { flag = arr[i]; }
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment