• + 11 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