Checks whether a given string is palindrome. Also return true whether it is almost palindrome whith error rate at most one char.
public static bool IsAlmostPalindrome(string word)
{
char[] normal = word.ToCharArray();
char[] reverse = word.ToCharArray();
Array.Reverse(reverse);
// Manualmente
//for (int i = normal.Length - 1, j = 0; i >= 0 ; i--, j++)
//{
// reverse[i] = normal[j];
//}
int erroCount = 0;
for (int i = 0; i < normal.Length; i++)
{
if (reverse[i] != normal[i])
erroCount += 1;
}
if(erroCount > 2)
return false;
return true;
}