➽ Problem:-

https://www.hackerrank.com/challenges/diagonal-difference/problem

➽ Solution:-

import java.util.*;

import java.io.*;

import java.math.*;

 

class Solution

{

    public static void main(String args[])

    {

        int N;

        Scanner sc = new Scanner(System.in);

       

        N = sc.nextInt();

       

        int[][] A = new int[N][N];

        int LDS=0, RDS=0;

       

        for(int i=0; i<N; i++)

        {

            for(int j=0; j<N; j++)

            {

                A[i][j] = sc.nextInt();

            }

        }

       

        for(int i=0; i<N; i++)

        {

            LDS += A[i][i];

        }

       

        for(int i=0, j=N-1; i<N; i++, j--)

        {

            RDS += A[i][j];

        }

       

        System.out.println(Math.abs(LDS - RDS));

    }

}