Skip to content

Commit 2ac4518

Browse files
author
owen
committed
feat : two-sum 문제풀이 완료
1 parent 5f500fe commit 2ac4518

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

two-sum/Kyojin-Hwang.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function twoSum(nums, target) {
2+
const map = new Map();
3+
4+
for (let i = 0; i < nums.length; i++) {
5+
const complement = target - nums[i];
6+
7+
if (map.has(complement)) {
8+
return [map.get(complement), i];
9+
}
10+
11+
map.set(nums[i], i);
12+
}
13+
}

0 commit comments

Comments
 (0)