Diagonal Difference

  • + 0 comments

    Solution in Python 3

    def diagonalDifference(arr):
        size = len(arr)
        lr = 0
        rl = 0
        for i in range(size):
            lr += arr[i][i]
            rl += arr[i][(size - 1) - i]
        return abs(lr - rl)