We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
keep in mind that; using multiple rotations, you can bring any number into the quadrant that you desire.
for any position in the upper left quadrant (position [x][y], where x and y < n (and not 2*n)), you can move numbers in any quadrant at the following positions to [x][y]:
[x][y] or // upper left quadrant
[x][2*n-1-y] or // upper right quadrant
[2*n-1-x][y], or // lower left quadrant
[2*n-1-x][2*n-1-y] // lower right quadrant
all you need to do then is, for every position (x and y) in the upper left quadrant, you need to find the maximum of the four numbers at the above positions, sum them and print the answer.
Note: Complexity is O(n) where n is the number of elements in the array
Flipping the Matrix
You are viewing a single comment's thread. Return to all comments →
keep in mind that; using multiple rotations, you can bring any number into the quadrant that you desire.
for any position in the upper left quadrant (position [x][y], where x and y < n (and not 2*n)), you can move numbers in any quadrant at the following positions to [x][y]:
[x][y] or // upper left quadrant [x][2*n-1-y] or // upper right quadrant [2*n-1-x][y], or // lower left quadrant [2*n-1-x][2*n-1-y] // lower right quadrant
all you need to do then is, for every position (x and y) in the upper left quadrant, you need to find the maximum of the four numbers at the above positions, sum them and print the answer.
Note: Complexity is O(n) where n is the number of elements in the array