Skip to content

Instantly share code, notes, and snippets.

@junaidkbr
Created September 15, 2020 14:18
Show Gist options
  • Save junaidkbr/d1a4bb11fdcf8bc85326defd3a59aea5 to your computer and use it in GitHub Desktop.
Save junaidkbr/d1a4bb11fdcf8bc85326defd3a59aea5 to your computer and use it in GitHub Desktop.
const twoSum = (numbers, target) => {
let indices = [];
for (let i = 0; i < numbers.length; i++) {
for (let j = 0; j < numbers.length; j++) {
if (i == j) {
continue;
}
if ((numbers[i] + numbers[j]) == target) {
indices = [i, j];
//console.log(indices);
break;
}
}
}
return indices;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment