You are viewing a single comment's thread. Return to all comments →
short c++ solution
int diagonalDifference(vector> arr) { int n = arr.size(); int d1 = 0, d2 = 0;
for (int i = 0; i < n; i++) { d1 += arr[i][i]; d2 += arr[i][n-1-i]; } return abs(d1-d2);
}
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 →
short c++ solution
int diagonalDifference(vector> arr) { int n = arr.size(); int d1 = 0, d2 = 0;
}