You are viewing a single comment's thread. Return to all comments →
function diagonalDifference(arr) { let sumLeftDiag = 0; let sumRightDiag = 0; for(let i = 0;i < arr.length; i++) { for(let j=i;j<i + 1;j++) { sumLeftDiag+=arr[i][j]; const revArr = [...arr[i]].reverse(); sumRightDiag+=revArr[i]; } } return Math.abs(sumRightDiag - sumLeftDiag); }
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 →