Given a string ,find if its permutation can be a palindrome

public class Solution { public bool CanPermutationPalindrome(string s) { var ht=new Hashtable(); for(int i=0;i<s.Length;i++){ if(ht.Contains(s[i])){ ht[s[i]]=(int)ht[s[i]]+ 1; } else{ ht.Add(s[i],1); } } if(ht.Keys.Count==1){ return true; } var count=0; var oddCount=0; foreach (var val in ht.Values) { var value=(int)val; if(value==1){ count++; } if(value%2==1 && value !=1){ oddCount++; } } if(count==0 && oddCount==0){ return true; } else if(count ==1 && oddCount==0){ return true; } else if(count ==0 && oddCount==1){ return true; } return false; } }
Code language: PHP (php)