Diagonal Difference

  • + 0 comments

    no need to two variables to calculate result. In Java public static int diagonalDifference(List> arr) { int n = arr.size(); int result =0; for (int i = 0; i < n; i++) { result += arr.get(i).get(i) - arr.get( i).get(n - i -1); } return Math.abs(result); }