Skip to content

Commit 3c94460

Browse files
authored
feat: add typescript solution to lc problem: No.0119.Pascal's Triangle II (#523)
1 parent c275db5 commit 3c94460

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/0100-0199/0119.Pascal's Triangle II/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ class Solution {
6464
}
6565
```
6666

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+
6781
### **C++**
6882

6983
```cpp

solution/0100-0199/0119.Pascal's Triangle II/README_EN.md

+14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ class Solution {
6565
}
6666
```
6767

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+
6882
### **C++**
6983

7084
```cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
};

0 commit comments

Comments
 (0)