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.
In Java i have solved in that way , sure there could be a better solution
` public static int diagonalDifference(List> arr) {
int rowSize = arr.size();
int ltrSum = 0;
int rtlSum = 0;
for(int i = 0; i < rowSize; i++) {
ltrSum = ltrSum + arr.get(i).get(i);
rtlSum = rtlSum + arr.get(i).get(rowSize - (i + 1));
}
return Math.abs(ltrSum - rtlSum);
}
}
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 →
In Java i have solved in that way , sure there could be a better solution ` public static int diagonalDifference(List> arr) { int rowSize = arr.size();
}