File tree 11 files changed +64
-3
lines changed
11 files changed +64
-3
lines changed Original file line number Diff line number Diff line change 82
82
| [ 111] [ 111-question ] | [ Minimum Depth of Binary Tree] [ 111-tips ] | [ Easy] [ E ] | [ ✅] [ 111-java ] | [ ✅] [ 111-js ] | [ ✅] [ 111-kotlin ] |
83
83
| [ 112] [ 112-question ] | [ Path Sum] [ 112-tips ] | [ Easy] [ E ] | [ ✅] [ 112-java ] | [ ✅] [ 112-js ] | [ ✅] [ 112-kotlin ] |
84
84
| [ 118] [ 118-question ] | [ Pascal's Triangle] [ 118-tips ] | [ Easy] [ E ] | [ ✅] [ 118-java ] | [ ✅] [ 118-js ] | [ ✅] [ 118-kotlin ] |
85
- | [ 119] [ 119-question ] | [ Pascal's Triangle II] [ 119-tips ] | [ Easy] [ E ] | [ ✅] [ 119-java ] | | [ ✅] [ 119-kotlin ] |
85
+ | [ 119] [ 119-question ] | [ Pascal's Triangle II] [ 119-tips ] | [ Easy] [ E ] | [ ✅] [ 119-java ] | [ ✅ ] [ 119-js ] | [ ✅] [ 119-kotlin ] |
86
86
| [ 121] [ 121-question ] | [ Best Time to Buy and Sell Stock] [ 121-tips ] | [ Easy] [ E ] | [ ✅] [ 121-java ] | | [ ✅] [ 121-kotlin ] |
87
87
| [ 122] [ 122-question ] | [ Best Time to Buy and Sell Stock II] [ 122-tips ] | [ Easy] [ E ] | [ ✅] [ 122-java ] | | [ ✅] [ 122-kotlin ] |
88
88
| [ 125] [ 125-question ] | [ Valid Palindrome] [ 125-tips ] | [ Easy] [ E ] | | | [ ✅] [ 125-kotlin ] |
@@ -462,6 +462,7 @@ commit信息模板: ``feat: add the solution of `Two Sum`(001) with Java``
462
462
[ 111-js ] : ./src/_111/Solution.js
463
463
[ 112-js ] : ./src/_112/Solution.js
464
464
[ 118-js ] : ./src/_118/Solution.js
465
+ [ 119-js ] : ./src/_119/Solution.js
465
466
[ 226-js ] : ./src/_226/Solution.js
466
467
[ 561-js ] : ./src/_561/Solution.js
467
468
[ 643-js ] : ./src/_643/Solution.js
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } rowIndex
3
+ * @return {number[] }
4
+ */
5
+ var getRow = function ( rowIndex ) {
6
+ var rowArr = function ( numRows ) {
7
+ let arr = [ ]
8
+ for ( var i = 1 ; i <= numRows ; i ++ ) {
9
+ if ( i === 1 ) {
10
+ arr . push ( [ 1 ] )
11
+ continue
12
+ }
13
+ if ( i === 2 ) {
14
+ arr . push ( [ 1 , 1 ] )
15
+ continue
16
+ }
17
+ let innerArr = [ 1 ]
18
+ for ( var j = 2 ; j < i ; j ++ ) {
19
+ innerArr . push ( arr [ i - 2 ] [ j - 2 ] + arr [ i - 2 ] [ j - 1 ] )
20
+ }
21
+ innerArr . push ( 1 )
22
+ arr . push ( innerArr )
23
+ }
24
+ return arr
25
+ }
26
+ return rowArr ( rowIndex + 1 ) [ rowIndex ]
27
+ } ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ class Solution {
78
78
}
79
79
```
80
80
81
-
81
+ JavaScript:
82
82
``` javascript
83
83
var isSymmetric = function (root ) {
84
84
if (root == null ) return true
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class Solution {
44
44
}
45
45
```
46
46
47
+ JavaScript:
47
48
``` javascript
48
49
var maxDepth = function (root ) {
49
50
if (root == null ) return 0 ;
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ class Solution {
119
119
}
120
120
```
121
121
122
+ JavaScript:
122
123
``` javascript
123
124
var levelOrderBottom = function (root ) {
124
125
if (root === null ) { return []; }
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class Solution {
85
85
}
86
86
```
87
87
88
+ JavaScript:
88
89
``` javascript
89
90
var sortedArrayToBST = function (nums ) {
90
91
if (nums == null || ! nums .length ) {
Original file line number Diff line number Diff line change @@ -59,7 +59,8 @@ class Solution {
59
59
```
60
60
61
61
62
- ```
62
+ JavaScript:
63
+ ``` JavaScript
63
64
var isBalanced = function (root ) {
64
65
if (root == null ) return true
65
66
var treeDeep = function (root ) {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class Solution {
48
48
}
49
49
```
50
50
51
+ JavaScript:
51
52
``` JavaScript
52
53
var minDepth = function (root ) {
53
54
if (root == null ) return 0
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ class Solution {
58
58
}
59
59
```
60
60
61
+ JavaScript:
61
62
``` JavaScript
62
63
var hasPathSum = function (root , sum ) {
63
64
if (root == null ) {
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class Solution {
69
69
}
70
70
```
71
71
72
+ JavaScript:
72
73
``` JavaScript
73
74
var generate = function (numRows ) {
74
75
let arr = []
Original file line number Diff line number Diff line change @@ -54,6 +54,32 @@ class Solution {
54
54
}
55
55
```
56
56
57
+ JavaScript:
58
+ ``` JavaScript
59
+ var getRow = function (rowIndex ) {
60
+ var rowArr = function (numRows ) {
61
+ let arr = []
62
+ for (var i = 1 ; i <= numRows; i++ ) {
63
+ if (i === 1 ) {
64
+ arr .push ([1 ])
65
+ continue
66
+ }
67
+ if (i === 2 ) {
68
+ arr .push ([1 , 1 ])
69
+ continue
70
+ }
71
+ let innerArr = [1 ]
72
+ for (var j = 2 ; j < i; j++ ) {
73
+ innerArr .push (arr[i- 2 ][j- 2 ] + arr[i- 2 ][j- 1 ])
74
+ }
75
+ innerArr .push (1 )
76
+ arr .push (innerArr)
77
+ }
78
+ return arr
79
+ }
80
+ return rowArr (rowIndex + 1 )[rowIndex]
81
+ };
82
+ ```
57
83
## 结语
58
84
59
85
如果你同我们一样热爱数据结构、算法、LeetCode,可以关注我们 GitHub 上的 LeetCode 题解:[ LeetCode-Solution] [ ls ]
You can’t perform that action at this time.
0 commit comments