You are viewing a single comment's thread. Return to all comments →
in C
int diagonalDifference(int arr_rows, int arr_columns, int** arr) { int LTRsum = 0, RTLsum = 0; for(int r=0,c=0;r<arr_rows && c<arr_columns;r++,c++){ /*LTR*/ LTRsum+=arr[r][c]; /*RTL*/ RTLsum+= arr[r][arr_columns-1-c]; } if((RTLsum-LTRsum) >= 0){ return RTLsum-LTRsum; }else { return LTRsum-RTLsum; } }
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 →
in C