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.
Basically for each element in the upper-left quadrant, there is a possible of 4 values that can fit there (no flip, flip vertical, flip horizontal, flip both).
So just write a code to identify each group of 4 values, then calculate the max of each 4-value group, and sum everything up together.
The elements of each group should have the following indexes:
- matrix[x][y], matrix[2n-1-x][y], matrix[x][2n-1-y], matrix[2n-1-x][2n-1-y]
- where x & y are indexes between 0 and n-1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Flipping the Matrix
You are viewing a single comment's thread. Return to all comments →
Basically for each element in the upper-left quadrant, there is a possible of 4 values that can fit there (no flip, flip vertical, flip horizontal, flip both).
So just write a code to identify each group of 4 values, then calculate the max of each 4-value group, and sum everything up together.
The elements of each group should have the following indexes: - matrix[x][y], matrix[2n-1-x][y], matrix[x][2n-1-y], matrix[2n-1-x][2n-1-y] - where x & y are indexes between 0 and n-1