You are viewing a single comment's thread. Return to all comments →
C#
public static int diagonalDifference(List<List<int>> arr) { int diagonal1 = 0; int diagonal2 = 0; int j = arr.Count - 1; for (int i = 0; i < arr.Count; i++) { diagonal1 += arr[i][i]; diagonal2 += arr[i][j]; j--; } return Math.Abs(diagonal1 - diagonal2); }
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#