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.
publicstaticinttheLoveLetterMystery(Strings){// Write your code hereintcount=0;StringBuildersb=newStringBuilder(s);Stringstr=sb.reverse().toString();if(s.contentEquals(str)){returncount;}else{for(inti=0;i<s.length()/2;i++){count+=Math.abs(s.charAt(i)-s.charAt(s.length()-1-i));}returncount;}}
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 →
Java 15