SHARE
TWEET

NickSubmissionChallenge1

a guest Oct 17th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int diagonalDifference(vector<vector<int>> arr)
  2. {
  3.     int n = arr.size();
  4.    
  5.     //Sum primary and secondary diagonal
  6.     int primaryDiag = 0;
  7.     int secondaryDiag = 0;
  8.     for (int i = 0; i < n; i++)
  9.     {
  10.         primaryDiag += arr[i][i];
  11.         secondaryDiag += arr[i][(n-1)-i];
  12.     }
  13.  
  14.     return abs(primaryDiag - secondaryDiag);
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top