You are viewing a single comment's thread. Return to all comments →
function diagonalDifference(arr) { const maxIndex = arr.length - 1; let diag1 = 0; let diag2 = 0; for (let i = 0; i < arr.length; i++) { diag1 += arr[i][i] diag2 += arr[i][maxIndex - i] } return Math.abs(diag1 - diag2); }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →