Skip to content

Instantly share code, notes, and snippets.

@Logan1x
Last active February 13, 2019 15:42
Show Gist options
  • Save Logan1x/fa13070a38f9984b12e0fe1e62efa75e to your computer and use it in GitHub Desktop.
Save Logan1x/fa13070a38f9984b12e0fe1e62efa75e to your computer and use it in GitHub Desktop.
Hackerrank solution
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