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