Answers for "diagonal difference hackerrank solution in python"

2

diagonal difference hackerrank python

prim =0
    sec=0
    length = len(arr[0])
    for count in range(length):
        prim += arr[count][count]
        sec += arr[count][(length-count-1)]
    return abs(prim-sec)
Posted by: Guest on May-10-2020
0

diagonal difference hackerrank solution in python

def diagonalDifference(arr):
    # Write your code here
    d1 =0
    d2=0
    for i in range(len(arr[0])):
        d1 += arr[i][i]
        d2 += arr[i][(len(arr[0])-i-1)]
    return abs(d1-d2)
Posted by: Guest on July-10-2021
0

diagonal difference hackerrank solution in python

def diagonalDifference(arr):
    # Write your code here
    d1 = sum([arr[x][x] for x in range(len(arr))])
    d2 = sum([arr[x][n - 1 - x] for x in range(len(arr))])
    return(abs(d1 - d2))
Posted by: Guest on March-24-2021

Code answers related to "diagonal difference hackerrank solution in python"

Python Answers by Framework

Browse Popular Code Answers by Language