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.
public static int theLoveLetterMystery(String s) {
int count=0;
int n=s.length();
int start=0;
int end=n-1;
while(start < end){
int st=s.charAt(start)-'a';
int en=s.charAt(end)-'a';
int diff=en-st;
if(diff==0){
start++;
end--;
continue;
}
if(en>st){
if(diff>0){
count=count+diff;
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →
in java
public static int theLoveLetterMystery(String s) { int count=0; int n=s.length(); int start=0; int end=n-1; while(start < end){ int st=s.charAt(start)-'a'; int en=s.charAt(end)-'a'; int diff=en-st; if(diff==0){ start++; end--; continue; } if(en>st){ if(diff>0){ count=count+diff;