File tree 3 files changed +48
-1
lines changed
3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 81
81
| [ 110] [ 110-question ] | [ Balanced Binary Tree] [ 110-tips ] | [ Easy] [ E ] | [ ✅] [ 110-java ] | [ ✅] [ 110-js ] | [ ✅] [ 110-kotlin ] |
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
- | [ 118] [ 118-question ] | [ Pascal's Triangle] [ 118-tips ] | [ Easy] [ E ] | [ ✅] [ 118-java ] | | [ ✅] [ 118-kotlin ] |
84
+ | [ 118] [ 118-question ] | [ Pascal's Triangle] [ 118-tips ] | [ Easy] [ E ] | [ ✅] [ 118-java ] | [ ✅ ] [ 118-js ] | [ ✅] [ 118-kotlin ] |
85
85
| [ 119] [ 119-question ] | [ Pascal's Triangle II] [ 119-tips ] | [ Easy] [ E ] | [ ✅] [ 119-java ] | | [ ✅] [ 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 ] |
@@ -461,6 +461,7 @@ commit信息模板: ``feat: add the solution of `Two Sum`(001) with Java``
461
461
[ 110-js ] : ./src/_110/Solution.js
462
462
[ 111-js ] : ./src/_111/Solution.js
463
463
[ 112-js ] : ./src/_112/Solution.js
464
+ [ 118-js ] : ./src/_118/Solution.js
464
465
[ 226-js ] : ./src/_226/Solution.js
465
466
[ 561-js ] : ./src/_561/Solution.js
466
467
[ 643-js ] : ./src/_643/Solution.js
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } numRows
3
+ * @return {number[][] }
4
+ */
5
+ var generate = function ( numRows ) {
6
+ let arr = [ ]
7
+ for ( var i = 1 ; i <= numRows ; i ++ ) {
8
+ if ( i === 1 ) {
9
+ arr . push ( [ 1 ] )
10
+ continue
11
+ }
12
+ if ( i === 2 ) {
13
+ arr . push ( [ 1 , 1 ] )
14
+ continue
15
+ }
16
+ let innerArr = [ 1 ]
17
+ for ( var j = 2 ; j < i ; j ++ ) {
18
+ innerArr . push ( arr [ i - 2 ] [ j - 2 ] + arr [ i - 2 ] [ j - 1 ] )
19
+ }
20
+ innerArr . push ( 1 )
21
+ arr . push ( innerArr )
22
+ }
23
+ return arr
24
+ } ;
Original file line number Diff line number Diff line change @@ -69,6 +69,28 @@ class Solution {
69
69
}
70
70
```
71
71
72
+ ``` JavaScript
73
+ var generate = function (numRows ) {
74
+ let arr = []
75
+ for (var i = 1 ; i <= numRows; i++ ) {
76
+ if (i === 1 ) {
77
+ arr .push ([1 ])
78
+ continue
79
+ }
80
+ if (i === 2 ) {
81
+ arr .push ([1 , 1 ])
82
+ continue
83
+ }
84
+ let innerArr = [1 ]
85
+ for (var j = 2 ; j < i; j++ ) {
86
+ innerArr .push (arr[i- 2 ][j- 2 ] + arr[i- 2 ][j- 1 ])
87
+ }
88
+ innerArr .push (1 )
89
+ arr .push (innerArr)
90
+ }
91
+ return arr
92
+ };
93
+ ```
72
94
## 结语
73
95
74
96
如果你同我们一样热爱数据结构、算法、LeetCode,可以关注我们 GitHub 上的 LeetCode 题解:[ LeetCode-Solution] [ ls ]
You can’t perform that action at this time.
0 commit comments