This commit is contained in:
Gleb Koval 2022-06-13 19:19:48 +01:00
parent 807ce27309
commit 3cc60d0431
Signed by: cyclane
GPG Key ID: 15E168A8B332382C
1 changed files with 10 additions and 0 deletions

10
triangle/sol.rs Normal file
View File

@ -0,0 +1,10 @@
impl Solution {
pub fn minimum_total(mut triangle: Vec<Vec<i32>>) -> i32 {
for row in (0..triangle.len() - 1).rev() {
for idx in 0..row + 1 {
triangle[row][idx] += triangle[row + 1][idx].min(triangle[row + 1][idx + 1]);
}
}
triangle[0][0]
}
}