Skip to content

Commit d178a2c

Browse files
committed
feat: add rust solution to lc problem: No.0199
No.0119.Pascal's Triangle II
1 parent 080e7b3 commit d178a2c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,23 @@ func getRow(rowIndex int) []int {
109109
}
110110
```
111111

112+
### **Rust**
113+
114+
```rust
115+
impl Solution {
116+
pub fn get_row(row_index: i32) -> Vec<i32> {
117+
let n = (row_index + 1) as usize;
118+
let mut res = vec![1; n];
119+
for i in 2..n {
120+
for j in (1..i).rev() {
121+
res[j] += res[j - 1];
122+
}
123+
}
124+
res
125+
}
126+
}
127+
```
128+
112129
### **...**
113130

114131
```

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ func getRow(rowIndex int) []int {
110110
}
111111
```
112112

113+
### **Rust**
114+
115+
```rust
116+
impl Solution {
117+
pub fn get_row(row_index: i32) -> Vec<i32> {
118+
let n = (row_index + 1) as usize;
119+
let mut res = vec![1; n];
120+
for i in 2..n {
121+
for j in (1..i).rev() {
122+
res[j] += res[j - 1];
123+
}
124+
}
125+
res
126+
}
127+
}
128+
```
129+
113130
### **...**
114131

115132
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
impl Solution {
2+
pub fn get_row(row_index: i32) -> Vec<i32> {
3+
let n = (row_index + 1) as usize;
4+
let mut res = vec![1; n];
5+
for i in 2..n {
6+
for j in (1..i).rev() {
7+
res[j] += res[j - 1];
8+
}
9+
}
10+
res
11+
}
12+
}

0 commit comments

Comments
 (0)