Concise Java Solution


  • 0
    public class Solution {
        public boolean canPermutePalindrome(String s) {
            int odd = 0;
            int[] count = new int[256];
            for (char c : s.toCharArray()) {
                count[c]++;
                if (count[c] == 1) odd++;
                else {
                    odd--;
                    count[c] = 0;
                }
            }
            return odd <= 1;
        }
    }
    

Log in to reply
 

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