// 1.4 Palindrome permutation
// 9/7/2017
public class PalindromePermutation {
    int getCharNumber(Character c) {
        int a = Character.getNumericValue('a');
        int z = Character.getNumericValue('z');
        int val = Character.getNumericValue(c);

        if (a <= val && val <= z)
            return val - a;
        else 
            return -1;
    }

    int[] buildCharFrequencyTable(String phrase) {
        int[] table = new int[Character.getNumericValue('z') - 
                              Character.getNumericValue('a') + 1];
        for (char c: phrase.toCharArray()) {
            int x = getCharNumber(c);
            if (x != -1)
                table[x]++;
        }
        return table;
    }

    boolean checkMaxOneOld(int[] table) {
        boolean foundOdd = false;
        for (int count: table) {
            if (count % 2 == 1) {
                if (foundOdd) return false;
                foundOdd = true;
            }
        }

        return true;
    }

    boolean isPermutationOfPalindrome(String phrase) {
        int[] table = buildCharFrequencyTable(phrase);
        return checkMaxOneOld(table);
    }

    public static void main(String[] args) {
    
    }
}

@@ -1141,24 +1141,1454 @@
 le);%0A    %7D%0A%0A
+    // Solution 2%0A    boolean isPermutationOfPalindrome2(String phrase) %7B%0A        int countOdd = 0;%0A        int%5B%5D table = new int%5BCharacter.getNumericValue('z') - Character.getNumericValue('a') + 1%5D;%0A%0A        for (char c: phrase.toCharArray()) %7B%0A            int x = getCharNumber(c);%0A            if (x != -1) %7B%0A                table%5Bx%5D++;%0A                if (table%5Bx%5D %25 2 == 1)%0A                    countOdd++;%0A                else%0A                    countOdd--;%0A            %7D%0A        %7D%0A%0A        return countOdd %3C= 1;%0A    %7D%0A%0A    // Solution 3%0A    boolean isPermutationOfPalindrome3(String phrase) %7B%0A        int bitVector = createBitVector(phrase);%0A        return bitVector == 0 %7C%7C checkExactlyOneBitSet(bitVector);%0A    %7D%0A%0A    int createBitVector(String phrase) %7B%0A        int bitVector = 0;%0A        for (char c: phrase.toCharArray()) %7B%0A            int x = getCharNumber(c);%0A            bitVector = toggle(bitVector, x);%0A        %7D%0A        return bitVector;%0A    %7D%0A%0A    int toggle(int bitVector, int index) %7B%0A        if (index %3C 0) return bitVector;%0A%0A        int mask = 1 %3C%3C index;%0A        if ((bitVector & mask) == 0) %7B %0A            // bit is 0, change it to 1%0A            bitVector %7C= mask;%0A        %7D else %7B%0A            // bit is 1, change it to 0%0A            bitVector &= ~mask;%0A        %7D%0A        return bitVector;%0A    %7D%0A%0A    boolean checkExactlyOneBitSet(int bitVector) %7B%0A        return (bitVector & (bitVector - 1)) == 0;%0A    %7D%0A%0A
     public s

palindrome permutation