Skip to content

Instantly share code, notes, and snippets.

@fullstuck
Created June 14, 2021 17:30
Show Gist options
  • Select an option

  • Save fullstuck/ff9785b9fdd2f68179b862995e6d9330 to your computer and use it in GitHub Desktop.

Select an option

Save fullstuck/ff9785b9fdd2f68179b862995e6d9330 to your computer and use it in GitHub Desktop.
function twoSums(nums, target){
let start = 0;
for(let i = 1; i < nums.length; i++){
let curr = nums[start];
if(curr + nums[i] == target)
return [start, i]
if(i == nums.length - 1){
start++
i = start
}
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment