You are viewing a single comment's thread. Return to all comments →
Javascript
function diagonalDifference(arr) { const len = arr.length; let d1 = 0; let d2 = 0; for(let i=0; i<len; i++) { d1+= arr[i][i]; d2+= arr[i][len-1-i]; } return Math.abs(d1 - d2); }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Javascript