// Entry point name must be "Solution"
using System;
public static class Solution
{
private static void Main()
{
Console.WriteLine("Hello, world!");
if (IsPalindrome("kayak"))
{
Console.WriteLine("Is palindrome");
}
}
private static bool IsPalindrome(string str)
{
if (str.Length == 0) return true;
int leftIndex = 0;
int rightIndex = str.Length - 1;
while (leftIndex < rightIndex)
{
if (!Char.IsLetterOrDigit(str[leftIndex]))
{
leftIndex++;
continue;
}
if (!Char.IsLetterOrDigit(str[rightIndex]))
{
rightIndex--;
continue;
}
if (Char.IsLetterOrDigit(str[leftIndex]) != Char.IsLetterOrDigit(str[rightIndex]))
{
return false;
}
leftIndex++;
rightIndex--;
}
return true;
}
}