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.
- Diagonal Difference
- Discussions
Diagonal Difference
Diagonal Difference
Sort by
recency
|
638 Discussions
|
Please Login in order to post a comment
public static int diagonalDifference(List> arr) { // Write your code here
for(int i=1; i<=arr.size();i++) { List intArray = arr.get(i-1); primaryDiagnolSum+=intArray.get(i-1); secondaryDiagnolSum+= intArray.get(arr.size()-i);
}
int difference = primaryDiagnolSum-secondaryDiagnolSum; return (difference<0)?difference*-1: difference;
Java 8 solution
Python solution
My solution in C++
My submission is Below: Please give inputs about the approach