File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 12
12
## [ Easy] ( https://leetcode.com/problemset/all/?difficulty=Easy ) 题解
13
13
| 题目 | 题解 | kotlin | JavaScript | Java |
14
14
| :-----------------: | -------------------------------------- | :--------------: | :-------: | :------------: |
15
- | [ 1] [ 1-question ] | [ Two Sum] [ 1-tips ] | [ ✅] [ 1-kotlin ] | | [ ✅] [ 1-java ] |
15
+ | [ 1] [ 1-question ] | [ Two Sum] [ 1-tips ] | [ ✅] [ 1-kotlin ] | [ ✅ ] [ 1-JavaScript ] | [ ✅] [ 1-java ] |
16
16
| [ 728] [ 728-question ] | [ Self Dividing Numbers] [ 728-tips ] | | | [ ✅] [ 728-java ] |
17
17
| [ 771] [ 771-question ] | [ Jewels and Stones] [ 771-tips ] | [ ✅] [ 771-kotlin ] | | [ ✅] [ 771-java ] |
18
18
| [ 804] [ 804-question ] | [ Unique Morse Code Words] [ 804-tips ] | | | [ ✅] [ 804-java ] |
28
28
29
29
## 贡献者名单
30
30
- 感谢[ @Mukyu ] ( https://github.com/Mukyu ) , 提供Java题解、文档整理。
31
+ - 感谢[ @taryn ] ( https://github.com/taryn2016 ) , 提供JavaScript题解、文档整理。
31
32
- 感谢[ @WangXin ] ( https://github.com/relish-wang ) , 提供kotlin题解、文档整理。
32
33
33
34
49
50
[ 2-kotlin ] : ./src/_2/kotlin/Solution.kt
50
51
[ 771-kotlin ] : ./src/_771/kotlin/Solution.kt
51
52
53
+ [ 1-JavaScript ] : ./src/_1/Solution.js
54
+
52
55
[ 1-java ] : ./src/_1/Solution.java
53
56
[ 2-java ] : ./src/_2/Solution.java
54
57
[ 728-java ] : ./src/_728/Solution.java
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @param {number } target
4
+ * @return {number[] }
5
+ */
6
+ var twoSum = function ( nums , target ) {
7
+ for ( let i = 0 ; i < nums . length - 1 ; i ++ ) {
8
+ res = target - nums [ i ]
9
+ for ( let j = i + 1 ; j < nums . length ; j ++ ) {
10
+ if ( nums [ j ] === res ) {
11
+ return [ i , j ]
12
+ }
13
+ }
14
+ if ( i === nums . length ) {
15
+ return [ ]
16
+ }
17
+ }
18
+ }
Original file line number Diff line number Diff line change @@ -52,3 +52,20 @@ class Solution {
52
52
}
53
53
}
54
54
```
55
+ ### JavaScript
56
+
57
+ ``` JavaScript
58
+ var twoSum = function (nums , target ) {
59
+ for (let i = 0 ; i < nums .length - 1 ; i++ ) {
60
+ res = target - nums[i]
61
+ for (let j = i + 1 ; j < nums .length ; j++ ) {
62
+ if (nums[j] === res) {
63
+ return [i, j]
64
+ }
65
+ }
66
+ if (i === nums .length ) {
67
+ return []
68
+ }
69
+ }
70
+ }
71
+ ```
You can’t perform that action at this time.
0 commit comments