We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
We can reduce the complexity by both loop at same time execute and no if condition like this:
i think its better approach instead of using two if condition.
for(int i = 0,j = n; i < n && j > 0; i++,j--){
diag1 += arr[i][i];
diag2 += arr[i][j];
}
Cookie support is required to access HackerRank
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 →
We can reduce the complexity by both loop at same time execute and no if condition like this: