Skip to content

Commit

Permalink
- Easy peasy
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Jul 28, 2024
0 parents commit 978cb66
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions _001_twoSum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
for (const index = 0; index < nums.length; index++) {
const remainder = target - nums[index];
const jindex = nums.indexOf(remainder);

if (jindex != -1 && jindex !== index) {
return [index, jindex];
}
}

return null;
};

0 comments on commit 978cb66

Please sign in to comment.