all InfoSec news
Diagonal Difference HackerRank solution
March 28, 2022, 4:57 a.m. | Anin Arafath
DEV Community dev.to
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
For example, the square matrix is shown below:
1 2 3
4 5 6
9 8 9
The left-to-right diagonal = 1 + 5 + 9 = 15 The right to left diagonal = 3 + 5 + 9 = 17, Their absolute difference is |15-17| = 2.
in c++
int diagonalDifference(vector<vector<int>> arr,int n) {
int lft=0,rit=0;
for(int i=0;i<n;i++){
lft += arr[i][i];
rit += arr[(n-i)][(n-i)];
} …
More from dev.to / DEV Community
Jobs in InfoSec / Cybersecurity
SOC 2 Manager, Audit and Certification
@ Deloitte | US and CA Multiple Locations
Cyber Systems Administration
@ Peraton | Washington, DC, United States
Android Security Engineer, Public Sector
@ Google | Reston, VA, USA
Lead Electronic Security Engineer, CPP - Federal Facilities - Hybrid
@ Black & Veatch | Denver, CO, US
Profissional Sênior de Compliance & Validação em TI - Montes Claros (MG)
@ Novo Nordisk | Montes Claros, Minas Gerais, BR
Principal Engineer, Product Security Engineering
@ Google | Sunnyvale, CA, USA