The Love-Letter Mystery

  • + 0 comments

    Here is my c++ solution to the problem, explanation here : https://youtu.be/gIUqS2xO6lg

    int theLoveLetterMystery(string s) {
        int ans = 0 , start = 0, end = s.size() - 1;
        while(start < end){
            ans += abs(s[start] - s[end]);
            start++; end--;
        }
        return ans;
    }