Skip to content

Commit 1fecd3c

Browse files
authored
Create twoSum.js
1 parent 0445468 commit 1fecd3c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

twoSum.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number[]} nums
3+
* @param {number} target
4+
* @return {number[]}
5+
*/
6+
var twoSum = function(nums, target) {
7+
for(let x = 0; x < nums.length; x++)
8+
{
9+
for(let y = x + 1; y < nums.length; y++)
10+
{
11+
//console.log([nums[x], nums[y]])
12+
if(nums[x] + nums[y] == target)
13+
{
14+
//console.log([x, y])
15+
return [x, y]
16+
}
17+
}
18+
19+
}
20+
};

0 commit comments

Comments
 (0)