MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / get_row

Function get_row

119-pascals-triangle-ii.rs:1–13  ·  view source on GitHub ↗
(row_index: i32)

Source from the content-addressed store, hash-verified

1pub fn get_row(row_index: i32) -> Vec<i32> {
2 let mut ret = vec![vec![1], vec![1, 1]];
3 for i in 2..=row_index as usize {
4 let mut tmp = vec![];
5 for j in 1..ret[i-1].len() {
6 tmp.push(ret[i-1][j] + ret[i-1][j-1])
7 }
8 tmp.push(1);
9 tmp.insert(0, 1);
10 ret.push(tmp);
11 }
12 ret[row_index as usize].clone()
13}
14
15fn main() {
16 println!("{:?}", get_row(0));

Callers

nothing calls this directly

Calls 2

insertMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected