Рет қаралды 62
Flipping the matrix 2Nx2N to find the max sum in the upper left quadrant NxN
---------------------------------------------------------------------------------------------------------------------
Solution is to find the max possible value that is possible for each cell in the
upper quadrant n x n of 2n x 2n matrix. For each cell in the upper quadrant, the only four possible values are a,b,c, d shown below
for row - 0 to n/2
for col - 0 to n/2
a = matrix[row][col]
b = matrix[n-1-row][col]
c = matrix[row][n-1-col]
d = matrix[n-1-row][n-1-col]
sum += max(a,b,c,d)
in the end, sum is the answer