Skip to content

Commit e77dac3

Browse files
committed
two sum solution
1 parent 79b4169 commit e77dac3

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

contains-duplicate/nowrobin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ var containsDuplicate = function(nums) {
66
return new Set(nums).size != nums.length;
77
};
88

9-
// 40ms 80.33MB
9+
// 40ms 80.33MB

two-sum/nowrobin.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+
7+
// 34ms 54mb
8+
var twoSum = function(nums, target) {
9+
for (let i = 0; i < nums.length; i++) {
10+
for (let j = i + 1; j < nums.length; j++) {
11+
if (nums[j] === target - nums[i]) {
12+
return [i, j];
13+
}
14+
}
15+
}
16+
return []
17+
};

0 commit comments

Comments
 (0)