You are viewing a single comment's thread. Return to all comments →
Java Solution:
public static int diagonalDifference(List<List<Integer>> arr) { int leftSum = 0; int rightSum = 0; for(int i=0; i<arr.size();i++){ List<Integer> row = arr.get(i); leftSum = leftSum + row.get(i); rightSum = rightSum + row.get(row.size() -1 - i); } return leftSum > rightSum ? (leftSum - rightSum) : (rightSum - leftSum); }
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 →
Java Solution: