Java: Beats 89.61%.


  • 0
        public boolean canPermutePalindrome(String s) {
            int count = 0;
            boolean[] charSet = new boolean[256];
            for(int i = 0; i < s.length(); ++i) {
                char c = s.charAt(i);
                count = count + (charSet[c] ? -1 : 1);
                charSet[c] = !charSet[c];
            }
            return count < 2;
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.