Palindrome Permutation
Solutions
Approach – Using hash table
public bool IsPermutationOfPalindrome(string str)
{
if (str is null)
return true;
int countOdd = 0;
var table = new Dictionary<int, int>();
foreach (char item in str!)
{
int x = Char.ToLower(item);
if (!table.ContainsKey(x))
{
table.Add(x, 1);
}
else
{
table[x]++;
}
if (table[x] % 2 == 1)
{
countOdd++;
}
else
{
countOdd--;
}
}
return countOdd <= 1;
}
Approach – Using bit vector

Last updated