Created
December 10, 2016 13:35
-
-
Save antonybudianto/96502115cec6ff2b715c86f62ae36c9c to your computer and use it in GitHub Desktop.
pair of sum
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 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