diagonal difference hackerrank python
prim =0
sec=0
length = len(arr[0])
for count in range(length):
prim += arr[count][count]
sec += arr[count][(length-count-1)]
return abs(prim-sec)
diagonal difference hackerrank python
prim =0
sec=0
length = len(arr[0])
for count in range(length):
prim += arr[count][count]
sec += arr[count][(length-count-1)]
return abs(prim-sec)
diagonal difference hackerrank solution in java 8 using list
public static int diagonalDifference(List<List<Integer>> arr) {
// Write your code here
int leftd=0;
int rightd=0;
int n=arr.size();
for(int i=0;i<n;i++)
{
leftd+=arr.get(i).get(i);
rightd+=arr.get(i).get(n-i-1);
}
int absd=Math.abs(leftd-rightd);
return absd;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us