Last active
February 13, 2019 15:42
-
-
Save Logan1x/fa13070a38f9984b12e0fe1e62efa75e to your computer and use it in GitHub Desktop.
Hackerrank solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func diagonalDifference(arr [][]int32) int32 { | |
i:=0 | |
j:=0 | |
var c int =0 | |
var d int = 0 | |
for(i<len(arr)){ | |
for(j<len(arr)){ | |
if(i==j){ | |
c = c+ int(arr[i][j]) | |
}else if(i+j<len(arr)){ | |
d = d+ int(arr[i][j]) | |
} | |
} | |
} | |
if((c-d)>0){ | |
return int32(c-d) | |
} else{ | |
return int32(d-c) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment