I want to write a method to determine if a given string is a palindrome. E.g. "Madam I'm Adam", or "A man, a plan, a canal, Panama".
The prototype for the function is: bool is_palindrome(charconst * str)
I have a simple logic to check for equality by moving forward & backward from extreme ends of the string.
But, i would like to know how many efficient ways to do this ? All ideas welcome from C++ gurus..
I'd be interested to see your algorithm for this. I would personally bung it into a std::string and use the STL algorithms to remove the spaces and punctuation and change the case before doing a reverse compare. But that's not necessarily very efficient.