Diagonal Difference

  • + 0 comments

    I had a slightly nuanced approach to what most people did, thought I'd share. Python

    def diagonalDifference(arr):
        length = len(arr)
        diff = 0
        for i in range(0, length):
            diff = diff - (arr[i][i] - arr[i][length-(1+i)])
            
        return abs(diff)