You are viewing a single comment's thread. Return to all comments →
C#:
> public static int diagonalDifference(List> arr) { var x1 = 0; var x2 = arr.Count() - 1; var sum1 = 0; var sum2 = 0; foreach (List j in arr){ sum1 += j[x1]; sum2 += j[x2]; x1++; x2--; } return Math.Abs(sum1-sum2); }
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 →
C#:
> public static int diagonalDifference(List> arr) { var x1 = 0; var x2 = arr.Count() - 1; var sum1 = 0; var sum2 = 0; foreach (List j in arr){ sum1 += j[x1]; sum2 += j[x2]; x1++; x2--; } return Math.Abs(sum1-sum2); }