Stone Piles Discussions | Algorithms | HackerRank
  • + 2 comments

    This problem can be solved without explicitly finding the reverse of the string.

    bool is_funny(string &s)
    {   
        for ( int i = 0, j = s.length() - 1 ; i <= j ;  )
        {
            if ( abs(s[i] - s[++i]) != abs(s[j] - s[--j]) )
                return false;
        }
        return true;    
    }