bool CheckPalindrome (string CheckString)
if (null == CheckString || 0 == CheckString.Length) return false;
for (int i = 0; i < CheckString.Length / 2; i++)
if (CheckString[i] != CheckString[CheckString.Length - 1 - i]) return false;
My goals were to keep the algorithm short and simple and to support a majority of common scenarios. Things not taken into account include treating spaces or accented characters in a special way, just to name two. My contribution to this thread is that a conditional
statement for the odd/evenness of a string is unnecessary because the integer division will always return an integer (leaving the remainer to mod). This means in the algorithm above even strings get compared to the last character and odd strings ignore the
mod character. Also, the use of iteration (as opposed to recursion) and array-index lookup make for very fast execution times on the order of O(n).