/*
思路是:建立一个hashset 存储字符 遍历整个string 如果没有这个字符则添加进去 有的话就删除, 最后判断 hashset的大小,如果<= 1就说明有回文序列,反之则没有;
*/
public class Solution {
/**
* @param s: the given string
* @return: if a permutation of the string could form a palindrome
*/
public boolean canPermutePalindrome(String s) {
// write your code here
Set<Character> hash = new HashSet<Character>();
for(char c : s.toCharArray()) {
if(hash.contains(c)) {
hash.remove(c);
} else {
hash.add(c);
}
}
return hash.size() <= 1;
}
}