• + 0 comments

    My python sollution`

    def hourglassSum(a):
        ma = -float('inf')
        for i in range(1,5):
            for j in range(1,5):
                top = bottom = 0
                for dy in [-1,0,1] :
                    top += a[i-1][j+dy]
                    bottom += a[i+1][j+dy]
                ma = max(ma,top + a[i][j] + bottom)
        return ma