The Love-Letter Mystery

  • + 0 comments

    Java solution:

         int count = 0;
         int start = 0;
         int end = s.length() - 1;
         while(true){
           if(start >= end)
             return count;
           int diff = Math.abs(s.charAt(start) - s.charAt(end));
           count += diff;
           start++;
           end--;
           }