You are viewing a single comment's thread. Return to all comments →
Can anyone tell whats wrong in this c++ code ?? Its giving wrong output.
int diagonalDifference(vector<vector<int>> arr) { int sum1=0; int sum2=0; for(int i=0;i<arr.size();i++){ sum1+=arr[i][i]; } for(int i=(arr.size()-1);i>=0;i--){ sum2+=arr[i][i]; } if(sum1>sum2){ return sum1-sum2; } else{ return sum2-sum1; } }
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 anyone tell whats wrong in this c++ code ?? Its giving wrong output.