Skip to main content
2 of 3
added 6 characters in body
Wolf
  • 313
  • 5
  • 18

I came to this somewhat picturesque solution:

#include <string>

bool is_palindromic(const std::string& s)
{
    std::string::const_iterator start = s.begin();
    std::string::const_iterator end = s.end();
    while (start < end) {
        if (*(start++) != *(--end)) {
            return false;
        }
    }
    return true;
}

...that doesn't handle the empty string in a specific way, but as palindromic.

Wolf
  • 313
  • 5
  • 18