Some error occured while loading page for you. Please try again.
You are viewing a single comment's thread. Return to all comments →
var arr = input.split("\n"); var newarr= arr.slice(1); for (k=0;k<newarr.length;k++){ var str=newarr[k]; var mid=Math.floor(str.length/2); var count=0; var diff=0; var j= str.length-1; for (let i=0;i<mid;i++){ diff=Math.abs(str.charCodeAt(j)-str.charCodeAt(i)); count+=diff; j--; } console.log(count); }
Add Reply Preview cancel
Create An Account
Or connect with
By signing up you agree to our Terms of Service and Privacy Policy
Add Reply Preview cancel