Created
May 19, 2022 07:33
-
-
Save topeogunleye/3aff9a666077d1a46bece80c2e72aaa0 to your computer and use it in GitHub Desktop.
Two Sum LeetCode Challenge
This file contains 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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
var twoSum = function(nums, target) { | |
const twoSums = [0,0]; | |
for (let i = 0; i < nums.length; i++) { | |
for (let j = i + 1; j < nums.length; j++) { | |
if (nums[i] + nums[j] === target) { | |
twoSums[0] = i | |
twoSums[1] = j | |
} | |
} | |
} | |
return twoSums | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment