You are viewing a single comment's thread. Return to all comments →
My c++ solution:
int diagonalDifference(vector> arr) { int diag1 = 0; int diag2 = 0; for(int i = 0; i
for(int i = 0; i<arr.size(); i++){ for(int j = 0; j<arr.size(); j++){ if(i+j==arr.size()-1){ diag2 += arr[i][j]; }else{ continue; } } } int diff = diag2 - diag1; if(diag2 - diag1 <0){ return -(diff); }else{ return diff; }
}
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 →
My c++ solution:
int diagonalDifference(vector> arr) { int diag1 = 0; int diag2 = 0; for(int i = 0; i
}