Problem of the day
If the grid is:
1 2
3 4
We can collect points from all cells as each cell lies on a diagonal. So, the maximum points will be 1+2+3+4 = 10.
The first line contains 'T', denoting the number of test cases.
For each Test :
The first line contains an integer ‘N’.
The next ‘N’ lines contain ‘N’ space separated integers each, representing the grid.
Print one integer, the maximum number of points you can gain from the grid.
You are not required to print the expected output. It has already been taken care of. Just implement the function.
1 <= 'T' <= 10
1 <= ‘N’ <= 1000.
1 <= ‘A[i][j]’ <= 1000, i ∈ [1,N], j ∈ [1,N]
Note: It is guaranteed that the sum of N^2 across all test cases will be at most 10^6.
Time Limit: 1 sec
2
3
1 2 3
4 5 6
7 8 9
1
5
25
5
For test case 1:
We can sum up all the elements that lie on the diagonals, namely 1+5+9+3+7 = 25.
For Test case 2:
Since there is only one element, we can take it.
1
2
4 5
6 7
22