1 2 3 4 5 6 7 8 9 10 11
fn main() { println!("Hello, world!"); } struct Solution {} impl Solution { pub fn diagonal_sum(mat: Vec<Vec<i32>>) -> i32 { mat.iter().enumerate() .fold(0, |acc, (i, row)| acc + row[i] + if i != row.len()-1 -i {row[row.len()-1 -i]} else {0}) } }