Skip to content

Commit b134c5e

Browse files
committed
add js solution to readme documents for leetcode problem: no.0001
1 parent 3e7dfab commit b134c5e

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

solution/0000-0099/0001.Two Sum/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ class Solution {
9393
}
9494
```
9595

96+
### **JavaScript**
97+
98+
```js
99+
var twoSum = function (nums, target) {
100+
const map = new Map();
101+
for (let i = 0; i < nums.length; i++) {
102+
if (map.has(target - nums[i])) {
103+
return [map.get(target - nums[i]), i];
104+
}
105+
map.set(nums[i], i);
106+
}
107+
return [];
108+
};
109+
```
110+
96111
### **...**
97112

98113
```

solution/0000-0099/0001.Two Sum/README_EN.md

+15
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ class Solution {
7979
}
8080
```
8181

82+
### **JavaScript**
83+
84+
```js
85+
var twoSum = function (nums, target) {
86+
const map = new Map();
87+
for (let i = 0; i < nums.length; i++) {
88+
if (map.has(target - nums[i])) {
89+
return [map.get(target - nums[i]), i];
90+
}
91+
map.set(nums[i], i);
92+
}
93+
return [];
94+
};
95+
```
96+
8297
### **...**
8398

8499
```

solution/0000-0099/0001.Two Sum/Solution.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ var twoSum = function (nums, target) {
4040
}
4141
map.set(nums[i], i);
4242
}
43+
return [];
4344
};

0 commit comments

Comments
 (0)