You are viewing a single comment's thread. Return to all comments →
def diagonalDifference(arr): sum1 = 0 sum2 = 0 for i in range(n): sum1 = sum1 +arr[i][i] sum2 = sum2 + arr[i][(n-1)-i] diff = abs(sum1 - sum2) return(diff)
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
def diagonalDifference(arr): sum1 = 0 sum2 = 0 for i in range(n): sum1 = sum1 +arr[i][i] sum2 = sum2 + arr[i][(n-1)-i] diff = abs(sum1 - sum2) return(diff)