//https://www.hackerrank.com/challenges/game-of-thrones
import java.io.*;

public class Solution {
    public static void main(String[] args) throws IOException{
        int N = 26;
        int OFFSET = 97;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] count = new int[N];
        
        //Count character occurrences
        char[] chars = br.readLine().toCharArray();
        for(char c : chars){
            count[c - OFFSET]++;
        }
        
        //Make sure each character occurs an even number of times
        //Except for one if the string's length is odd
        boolean isPalindrome = true;
        boolean isOddCharFound = false;
        boolean isEvenLength = (chars.length & 1) == 0;
        for(int v : count){
            if ((v&1) == 1){
                if (isEvenLength || isOddCharFound){
                    isPalindrome = false;
                    break;
                }
                isOddCharFound = true;
            }
        }
        System.out.print(isPalindrome ? "YES" : "NO");
    }
}
@@ -164,55 +164,8 @@
 n%7B%0D%0A
-        int N = 26;%0D%0A        int OFFSET = 97;%0D%0A
     
@@ -255,82 +255,319 @@
     
-int%5B%5D count = new int%5BN%5D;%0D%0A        %0D%0A        //Count character occurrences
+System.out.print(isPalindromePermutation(br.readLine()) ? %22YES%22 : %22NO%22);%0D%0A        br.close();%0D%0A    %7D%0D%0A    %0D%0A    // Check if input is permutation of a palindrome%0D%0A    // For definition of a palindrome, see: https://en.wikipedia.org/wiki/Palindrome%0D%0A    private static boolean isPalindromePermutation(String str)%7B
 %0D%0A  
@@ -587,29 +587,19 @@
 chars = 
-br.readLine()
+str
 .toCharA
@@ -619,319 +619,211 @@
     
-for(char c : chars)%7B%0D%0A            count%5Bc - OFFSET%5D++;%0D%0A        %7D%0D%0A        %0D%0A        //Make sure each character occurs an even number of times%0D%0A        //Except for one if the string's length is odd%0D%0A        boolean isPalindrome = true;%0D%0A        boolean isOddCharFound = false;%0D%0A        boolean isEvenLength
+%0D%0A        //Track even-ness of letters%0D%0A        int bits = 0;%0D%0A        %0D%0A        //For every character in the input string%0D%0A        //Get the character's ASCII code and update bits%0D%0A        int strLen
  = 
-(
 char
@@ -834,18 +834,8 @@
 ngth
- & 1) == 0
 ;%0D%0A 
@@ -853,103 +853,69 @@
 int 
-v : count)%7B%0D%0A            if ((v&1) == 1)%7B%0D%0A                if (isEvenLength %7C%7C isOddCharFound
+i = 0; i %3C strLen; bits = bits %5E (1 %3C%3C (chars%5Bi++%5D - 'a'))
 )%7B
+%7D
 %0D%0A  
@@ -916,33 +916,34 @@
 %7B%7D%0D%0A        
- 
+%0D%0A
         
    isPalindr
@@ -934,32 +934,30 @@
     
-   isPalindrome = false;
+//Check if palindrome:
 %0D%0A  
@@ -966,45 +966,82 @@
     
+//
    
-         break;%0D%0A                %7D
+- Iff str length is even, no letter can appear an odd amount of times
 %0D%0A  
@@ -1050,119 +1050,135 @@
     
+//
    
-     isOddCharFound = true;%0D%0A            %7D%0D%0A        %7D%0D%0A        System.out.print(isPalindrome ? %22YES%22 : %22NO%22)
+- Iff str length is odd, one letter must appear an odd amount of times%0D%0A        return (bits & (bits - (strLen & 1))) == 0
 ;%0D%0A 
@@ -1184,8 +1184,10 @@
     %7D%0D%0A%7D
+%0D%0A

Update game-of-thrones.java