Diagonal Difference

  • + 1 comment
    public static int diagonalDifference(List<List<Integer>> arr) {
            var lr = 0;
            var rl = 0;
            var size = arr.size();
            for (int i = 0, j = size - 1; i < size; i++, j--) {
                lr += arr.get(i).get(i);
                rl += arr.get(i).get(j);
            }
            return Math.abs(lr-rl);
        }