Diagonal Difference

  • + 0 comments
    def diagonalDifference(arr):
        sumleft = 0
        sumright = 0
        for i in range(len(arr)):
            for j in range(len(arr)):
                if i == j:
                    sumleft+=arr[i][j]
                    print(sumleft)
                if i+j==len(arr)-1:
                    sumright+=arr[i][j]                
            diff = abs(sumleft-sumright)
        
        return diff