You are viewing a single comment's thread. Return to all comments →
O(N)Solution -
l=0 p=0 for i in range(len(a)): l+= a[i][i] p+= a[i][len(a)-1-i]
print(abs(l-p))
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 →
O(N)Solution -
l=0 p=0 for i in range(len(a)): l+= a[i][i] p+= a[i][len(a)-1-i]
print(abs(l-p))