You are viewing a single comment's thread. Return to all comments →
Why complexity of nested loop? This is how I solved it:
long sum1 = 0; long sum2 = 0;
for (int i = 0; i < n ; i++) { sum1 += a[i][i]; sum2 += a[i][n - 1 - i]; } Console.WriteLine(Math.Abs(sum1 - sum2));
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 →
Why complexity of nested loop? This is how I solved it:
long sum1 = 0; long sum2 = 0;