You are viewing a single comment's thread. Return to all comments →
A rust solution:
fn diagonalDifference(arr: &[Vec<i32>]) -> i32 { let len = arr.len(); let (diag_first, diag_second) = (0..len).fold((0, 0), |mut acc, i| { acc.0 += arr[i][i]; acc.1 += arr[i][len - 1 - i]; acc }); (diag_first - diag_second).abs() }
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
A rust solution: