Skip to content

Commit e8aed28

Browse files
committed
two-sum solution
1 parent 150a435 commit e8aed28

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

two-sum/nayeongdev.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+
for (let i = 0; i < nums.length; i++) {
8+
for (let j = i + 1; j < nums.length; j++) {
9+
if (nums[i] + nums[j] === target) {
10+
return [i, j];
11+
}
12+
if (nums[i] + nums[j] > target) {
13+
continue;
14+
}
15+
}
16+
}
17+
return [];
18+
};

0 commit comments

Comments
 (0)