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.
functiontheLoveLetterMystery(s:string):number{letoperations=0// Calculate the sum of the differences between opposite pairs of characters (number ascii).for(leti=0;i<Math.floor(s.length/2);i++){letreverse_i=s.length-i-1if(s[i]!=s[reverse_i]){operations+=Math.abs(s.charCodeAt(i)-s.charCodeAt(reverse_i))}}returnoperations}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →
My answer with Typescrippt, simple