266. Palindrome Permutation

class Solution {
public:
    bool canPermutePalindrome(string s) {
        unordered_map<char, int> count;

        for (char c : s)
            count[c]++;

        bool single = false;

        for (auto cnt : count) 
            if (cnt.second % 2) {
                if (single) return false;
                single = true;
            }

        return true;

    }
};

results matching ""

    No results matching ""