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
|
312 Discussions
|
Please Login in order to post a comment
in python
def diagonalDifference(arr): # Write your code here i=0 a=-1 l1=[] l2=[] for i in range(len(arr)): l1.append(arr[i][i]) i+=1 for i in range(len(arr)): l2.append(arr[i][a]) a-=1 i+=1 result=(sum(l1)-sum(l2)) return(abs(result))
in JavaScript:
int diagonalDifference(vector> arr) {
}
JAVA code public static int diagonalDifference(List> arr) { // Write your code here int primaryDiagonalSum = 0; int secondaryDiagonalSum = 0;
short c++ solution
int diagonalDifference(vector> arr) { int n = arr.size(); int d1 = 0, d2 = 0;
}