You are viewing a single comment's thread. Return to all comments →
My solution:
public static int diagonalDifference(List<List<int>> arr) { int sizeCol = arr[0].Count; int diagonal1 = 0; int diagonal2 = 0; for(int i = 0; i<arr.Count; i++){ for(int j = 0; j<sizeCol; j++){ if(arr[i][j] < - 100 || arr[i][j] > 100) throw new Exception("Numero invalido"); if(i == j) diagonal1 += arr[i][j]; } diagonal2 += arr[i][sizeCol - i - 1]; } 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 →
My solution: