Created
December 22, 2016 19:41
-
-
Save cacheflow/b405715a2907e149bee3e21fd3837284 to your computer and use it in GitHub Desktop.
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 findSum(list, sum) { | |
let listCopy = list.slice(0).sort() | |
let start = 0 | |
let end = list.length - 1 | |
while(start <= end ) { | |
if(list[start] + list[end] == sum) { | |
return true | |
} | |
else if(list[start] + list[end] > sum) { | |
start += 1 | |
} | |
else if(list[start] + list[end] < sum) { | |
end -= 1 | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment