Here is the problem description from Hackerrank.
Sean invented a game involving a matrix where each cell of the matrix contains an integer. He can reverse any of its rows or columns any number of times, and the goal of the game is to maximize the sum of the elements in the submatrix located in the upper-left corner of the matrix (i.e., its upper-left quadrant).
Given the initial configurations for matrices, help Sean reverse the rows and columns of each matrix in the best possible way so that the sum of the elements in the matrix's upper-left quadrant is maximal. For each matrix, print the maximized sum on a new line.
Input Format
The first line contains an integer, , denoting the number of queries. The subsequent lines describe each of the queries in the following format:
- The first line of each query contains an integer, .
- Each line the subsequent lines contains space-separated integers describing the respective values of row in the matrix.
Corners of a square matrix remain corners no matter how many times you invert themUsing that hint to find the max,
In a 4X4 matrix
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
14
|
15
|
16
|