Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
Created September 2, 2025 23:54
Show Gist options
  • Save AbeEstrada/e08a4b00513088f400626428c4ebf80a to your computer and use it in GitHub Desktop.
Save AbeEstrada/e08a4b00513088f400626428c4ebf80a to your computer and use it in GitHub Desktop.
Exercise: Diagonal Difference
function diagonalDifference(arr) {
let left = 0;
let right = 0;
const n = arr.length;
for (let i = 0; i < n; i++) {
left += arr[i][i];
right += arr[i][n - i - 1];
}
return Math.abs(left - right);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment