You are viewing a single comment's thread. Return to all comments →
let n = arr.length; let primarySum = 0; let secondarySum = 0;
for (let i = 0; i < n; i++) { primarySum += arr[i][i]; secondarySum += arr[i][n - 1 - i]; } return Math.abs(primarySum - secondarySum);
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 →
let n = arr.length; let primarySum = 0; let secondarySum = 0;