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.
The Love-Letter Mystery
The Love-Letter Mystery
Sort by
recency
|
945 Discussions
|
Please Login in order to post a comment
in Java
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;
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;
In Cpp