@@ -0,0 +1,1245 @@
+package string;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class PalindromePermutation %7B%0A%0A    //TAG: Uber%0A    //TAG: String%0A%0A    /**%0A     * 266. Palindrome Permutation%0A     * Given a string, determine if a permutation of the string could form a palindrome.%0A%0A     For example,%0A     %22code%22 -%3E False, %22aab%22 -%3E True, %22carerac%22 -%3E True.%0A     */%0A%0A    /**%0A     * Solution:%0A     * Go over s, when frequency is odd number 1, add a global number++, if the frequency is 1, minus it by 1 to 0,%0A     * and decrease global number--%0A     * at last, check if global number is smaller than 1 (kind like aba is palindrome)%0A     * Use HashMap to filter the frequency, due to not say it's lowercase or letter/number only, may unicode%0A     *%0A     * Time: O(n)%0A     * Space: O(n)%0A     */%0A%0A    public boolean canPermutePalindrome(String s) %7B%0A        Map%3CCharacter, Integer%3E map = new HashMap%3C%3E();%0A        int res = 0;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char cur = s.charAt(i);%0A            if (!map.containsKey(cur) %7C%7C map.get(cur) == 0) %7B%0A                map.put(cur, 1);%0A                res++;%0A            %7D else %7B%0A                map.put(cur, 0);%0A                res--;%0A            %7D%0A        %7D%0A        return res %3C= 1;%0A    %7D%0A%0A%7D%0A

266. Palindrome Permutation