From 48ea4a814b18c48c48a2676fcf1b6df82771430c Mon Sep 17 00:00:00 2001 From: devenperez <63876261+devenperez@users.noreply.github.com> Date: Wed, 6 Apr 2022 15:59:43 -0400 Subject: [PATCH] Time: 173 ms (24.71%), Space: 42.1 MB (93.26%) - LeetHub --- 1-two-sum/1-two-sum.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 1-two-sum/1-two-sum.js diff --git a/1-two-sum/1-two-sum.js b/1-two-sum/1-two-sum.js new file mode 100644 index 0000000..56e2ac7 --- /dev/null +++ b/1-two-sum/1-two-sum.js @@ -0,0 +1,14 @@ +/** + * @param {number[]} nums + * @param {number} target + * @return {number[]} + */ +var twoSum = function(nums, target) { + for(let i = 0; i < nums.length; i++) { + for(let j = i + 1; j < nums.length; j++) { + if(nums[i] + nums[j] == target) { + return [i, j]; + } + } + } +}; \ No newline at end of file