File tree 3 files changed +37
-0
lines changed
solution/0100-0199/0119.Pascal's Triangle II
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,20 @@ class Solution {
64
64
}
65
65
```
66
66
67
+ ### ** TypeScript**
68
+
69
+ ``` ts
70
+ function getRow(rowIndex : number ): number [] {
71
+ let ans = new Array (rowIndex + 1 ).fill (1 );
72
+ for (let i = 2 ; i < rowIndex + 1 ; ++ i ) {
73
+ for (let j = i - 1 ; j > 0 ; -- j ) {
74
+ ans [j ] += ans [j - 1 ];
75
+ }
76
+ }
77
+ return ans ;
78
+ };
79
+ ```
80
+
67
81
### ** C++**
68
82
69
83
``` cpp
Original file line number Diff line number Diff line change @@ -65,6 +65,20 @@ class Solution {
65
65
}
66
66
```
67
67
68
+ ### ** TypeScript**
69
+
70
+ ``` ts
71
+ function getRow(rowIndex : number ): number [] {
72
+ let ans = new Array (rowIndex + 1 ).fill (1 );
73
+ for (let i = 2 ; i < rowIndex + 1 ; ++ i ) {
74
+ for (let j = i - 1 ; j > 0 ; -- j ) {
75
+ ans [j ] += ans [j - 1 ];
76
+ }
77
+ }
78
+ return ans ;
79
+ };
80
+ ```
81
+
68
82
### ** C++**
69
83
70
84
``` cpp
Original file line number Diff line number Diff line change
1
+ function getRow ( rowIndex : number ) : number [ ] {
2
+ let ans = new Array ( rowIndex + 1 ) . fill ( 1 ) ;
3
+ for ( let i = 2 ; i < rowIndex + 1 ; ++ i ) {
4
+ for ( let j = i - 1 ; j > 0 ; -- j ) {
5
+ ans [ j ] += ans [ j - 1 ] ;
6
+ }
7
+ }
8
+ return ans ;
9
+ } ;
You can’t perform that action at this time.
0 commit comments