Skip to content

Instantly share code, notes, and snippets.

@cixuuz
Created September 13, 2017 22:09
Show Gist options
  • Save cixuuz/6f5836ae2994b8be71723164010be89a to your computer and use it in GitHub Desktop.
Save cixuuz/6f5836ae2994b8be71723164010be89a to your computer and use it in GitHub Desktop.
[266. Palindrome Permutation] #leetcode
class Solution {
// O(n) O(n)
public boolean canPermutePalindrome(String s) {
HashSet<Character> set = new HashSet<Character>();
for (Character c : s.toCharArray()) {
if (!set.add(c)) {
set.remove(c);
}
}
return set.size() < 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment