You are viewing a single comment's thread. Return to all comments →
can be done in ((n-1)/2)+1 iteration
for (int i = 0; i < ((n - 1) / 2) + 1; i++) { total = ar[i][i] - ar[i][n - 1 - i] + ((i != n - 1 - i) ? ar[n - 1 - i][n - 1 - i] - ar[n - 1 - i][i] : 0) + total; }
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 →
can be done in ((n-1)/2)+1 iteration