We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def diagonalDifference(arr):
# Write your code here
i=0
a=-1
l1=[]
l2=[]
for i in range(len(arr)):
l1.append(arr[i][i])
i+=1
for i in range(len(arr)):
l2.append(arr[i][a])
a-=1
i+=1
result=(sum(l1)-sum(l2))
return(abs(result))
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
in python
def diagonalDifference(arr): # Write your code here i=0 a=-1 l1=[] l2=[] for i in range(len(arr)): l1.append(arr[i][i]) i+=1 for i in range(len(arr)): l2.append(arr[i][a]) a-=1 i+=1 result=(sum(l1)-sum(l2)) return(abs(result))