You are viewing a single comment's thread. Return to all comments →
function diagonalDifference(arr) { let sum1=0,sum2=0,i,j,k,l,result; let n = arr.length - 1; k=n; for(l=0; l<arr.length; l++){ sum1 = sum1 + arr[k][l]; k--; } for(i=0; i<arr.length; i++){ sum2 = sum2 + arr[i][i]; } if(sum1>sum2){ result = sum1 - sum2 }else{ result = sum2 - sum1 } return result }
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 →