Skip to content

Commit 6c45680

Browse files
committed
two-sum solution
1 parent 511c793 commit 6c45680

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

two-sum/minji0214.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function twoSum(nums: number[], target: number): number[] {
2+
let answer = []
3+
for(let i = 0 ; i < nums.length; i ++){
4+
let temp = target - nums[i]
5+
if (nums.includes(temp) && temp != nums[i]) {
6+
const index = nums.findIndex((test) => test === temp )
7+
answer.push(index)
8+
}
9+
}
10+
return answer
11+
};

0 commit comments

Comments
 (0)