Created
September 13, 2017 22:09
-
-
Save cixuuz/6f5836ae2994b8be71723164010be89a to your computer and use it in GitHub Desktop.
[266. Palindrome Permutation] #leetcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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