Skip to content

Commit 30ee08a

Browse files
committed
Day59
1 parent aed0a32 commit 30ee08a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Day59/index.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+
let map = {};
8+
9+
for(let i=0; i < nums.length; i++){
10+
let y = target - nums[i];
11+
12+
if((y in map)){
13+
return [map[y], i]
14+
}else{
15+
map[nums[i]] = i;
16+
}
17+
}
18+
19+
return [-1,-1]
20+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
133133

134134
|Day 57| [1492. The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n/) | [javascript]()|[:memo:](https://leetcode.com/problems/the-kth-factor-of-n/)|Medium|
135135

136-
|Day 58| [117. Populating Next Right Pointers in Each Node II](hhttps://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) | [javascript]()|[:memo:](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/)|Medium|
136+
|Day 58| [117. Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) | [javascript]()|[:memo:](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/)|Medium|
137+
138+
|Day 59| [1. Two Sum](https://leetcode.com/problems/two-sum/) | [javascript]()|[:memo:](https://leetcode.com/problems/two-sum/)|Easy|

0 commit comments

Comments
 (0)