Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Maximum Direction in a Matrix

By tahmedge, ishtupeed · Limits 1s, 512 MB

The Great Researcher Mr. Bari will give you some chocolates from Singapore if you can solve the following problem.

You are given an n*n array. You have to find out in which direction the maximum sum of numbers is located. Is it through any row, or any column or one of the two diagonals?


First you will take an integer number n(1≤n≤100) as input. In the following n lines, you will take n numbers as input in each of the lines. The numbers will be in range [-100, 100].


Compute the value of maximum sum of numbers through any direction(row wise or column wise or diagonally).


1 2 3
4 5 6
7 8 9

In the sample, maximum sum of numbers is through the last row which is 24.



    88% Solution Ratio

    MU_SubMairaDkhEarliest, May '18

    rogue_33Fastest, 0.0s

    shoumoLightest, 131 kB

    touhidurShortest, 201B


    Login to submit

    Related Contests

    1st AUB Inter University Programming Contest 2018 Ended at 2018-05-12 10:10:00 +0000 UTC
    Replay of 1st AUB Inter University Programming Contest 2018 Ended at 2018-05-15 14:30:00 +0000 UTC