Skip to content

Commit b8001ee

Browse files
committed
📝 Solved: 1weeks two sum
1 parent 53ce7c7 commit b8001ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

two-sum/jangwonyoon.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number[]} nums
3+
* @param {number} target
4+
* @return {number[]}
5+
*/
6+
var twoSum = function(nums, target) {
7+
const length = nums.length - 1;
8+
9+
for (let i = 0; i < length; i++) {
10+
for (let j = length; j > 0; j--) {
11+
const sum = nums[i] + nums[j];
12+
13+
if (sum === target) {
14+
return [i, j];
15+
}
16+
}
17+
}
18+
};

0 commit comments

Comments
 (0)