Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Created April 16, 2019 16:43
Show Gist options
  • Select an option

  • Save 4skinSkywalker/9c4fa2f8e0d28a73f6d1d314f5d4e4d4 to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/9c4fa2f8e0d28a73f6d1d314f5d4e4d4 to your computer and use it in GitHub Desktop.
function sumZero(array) {
let left = 0
let right = array.length - 1
while (left < right) {
let sum = array[left] + array[right]
if (sum === 0)
return true
if (sum > 0)
right--
else
left++
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment