Skip to content

Commit f4e21bc

Browse files
authored
feat: two-sum 풀이 작성
1 parent 9d9d3b9 commit f4e21bc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

two-sum/hozzijeong.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 - 1; i++){
8+
const first = nums[i];
9+
for(let j = i + 1; j < nums.length; j++){
10+
const last = nums[j];
11+
12+
if((first + last) === target) return [i,j]
13+
}
14+
}
15+
16+
return []
17+
};

0 commit comments

Comments
 (0)