Print Matrix in Snake Pattern
Print Matrix in Snake Pattern
diagonals.
123
456
989
The left-to-right diagonal = . The right to left diagonal = . Their absolute
difference is .
Function description
Return
Input Format
The first line contains a single integer, , the number of rows and columns in the
square matrix .
integers .
Constraints
Output Format
Return the absolute difference between the sums of the matrix's two diagonals
as a single integer.
Sample Input
3
11 2 4
456
10 8 -12
Sample Output
15
Explanation
11
5
-12
Sum across the primary diagonal: 11 + 5 - 12 = 4
4
5
10
Sum across the secondary diagonal: 4 + 5 + 10 = 19
Difference: |4 - 19| = 15
Output : 10 20 30 40 45 35 25 15 27 29
37 48 50 39 33 32