Skip to content

Commit 15ab7de

Browse files
committed
two-sum.js
1 parent f546345 commit 15ab7de

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

1-two-sum/1-two-sum.js

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

0 commit comments

Comments
 (0)