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.
You've actually got 3xN conditions, counting all your loops, but I like your thinking.
Here's my solution from JavaScript:
var n = parseInt(readLine());
var suma = 0, sumb = 0;
for(var i = 0; i < n; i++){
var line = readLine().split(' ');
suma += Number(line[i]);
sumb += Number(line[n-i-1]);
}
console.log(Math.abs(sumb-suma));
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
You've actually got 3xN conditions, counting all your loops, but I like your thinking.
Here's my solution from JavaScript: