Diagonal Difference

  • + 0 comments

    primary = 0 secondary = 0

    for i in range(len(arr)):
        primary += arr[i][i]  # Main diagonal
        secondary += arr[i][len(arr) - 1 - i]  # Secondary diagonal
    
    return abs(primary - secondary)
        for python