class Solution {
public boolean canPermutePalindrome(String s) {
Map<Character, Integer> chars = new HashMap<>();
for (char c : s.toCharArray()){
if (chars.containsKey(c)){ // 判断该key在map中是否有key存在
chars.put(c, chars.get(c)+1);
}else{
chars.put(c, 1);
}
}
// 提出map遍历字符统计次数
int Count = 0;
for (int x :chars.values()){
if (x%2 != 0){
Count++;
}
}
if (Count>1){ // 统计Count即字符个数为奇数的个数
return false;
}
return true;
}
}