Skip to content

Instantly share code, notes, and snippets.

@piusayowale
Created August 17, 2022 20:01
Show Gist options
  • Save piusayowale/c6985de0a37fe77a8ace3a0688877d98 to your computer and use it in GitHub Desktop.
Save piusayowale/c6985de0a37fe77a8ace3a0688877d98 to your computer and use it in GitHub Desktop.
int diagonalDifference(vector<vector<int>> arr) {
int suma = 0;
int sumb = 0;
int n = arr.size();
for(int i = 0; i < n; i++){
cout << arr[i][i] << "\n";
sumb = sumb + arr[i][i];
}
cout << "\n\n";
int l = n - 1;
for(int i = 0; i < n; i++){
cout << arr[i][l] << "\n";
suma = suma + arr[i][l];
l--;
}
return abs(suma - sumb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment