You are viewing a single comment's thread. Return to all comments →
I see people using nested loops to solve this. I think it is not necessary. Here's my JS code:
var lr = rl = 0; for(var i = 0; i<n; i++){ lr += a[i][i]; rl += a[i][n-i-1]; } console.log(Math.abs(lr-rl));
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
I see people using nested loops to solve this. I think it is not necessary. Here's my JS code: