You are viewing a single comment's thread. Return to all comments →
My Typescript solution:
function diagonalDifference(arr: number[][]): number { let ltrDiagonalSum = 0; let rtlDiagonalSum = 0; const length = arr.length; for (let i = 0; i < length; i++) { ltrDiagonalSum += arr[i][i]; rtlDiagonalSum += arr[i][length - 1 - i]; } return Math.abs(ltrDiagonalSum - rtlDiagonalSum); }
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 →
My Typescript solution: