Aarti
BAN USERBelow code is written in c#
public static void CheckEWordIsPalindrome(string inputString)
{
Hashtable ht = new Hashtable();
if (!string.IsNullOrEmpty(inputString))
{
for (int counter = 0; counter < inputString.Length; counter++)
{
if (ht.Contains(inputString[counter]))
{
ht[inputString[counter]] = Convert.ToInt32(ht[inputString[counter]]) + 1;
}
else
{
ht.Add(inputString[counter], 1);
}
}
int odd = 0; ;
foreach (DictionaryEntry entry in ht)
{
if (Convert.ToInt32(entry.Value) == 1)
{
odd++;
}
}
if (odd > 1)
Console.WriteLine("Word is not Palindrome");
else
Console.WriteLine("Word is Palindrome");
Console.ReadLine();
}
else
{
Console.WriteLine("Input string is empty!!"); ;
Console.ReadLine();
}
}
- Aarti April 07, 2015