Diagonal Difference

  • + 0 comments

    We can reduce the complexity by both loop at same time execute and no if condition like this:

        i think its better approach instead of using two if condition.
    
        for(int i = 0,j = n; i < n && j > 0; i++,j--){
            diag1 += arr[i][i];
            diag2 += arr[i][j];
        }