Posted on

Description

Submission

class Solution {
public:
    bool canPermutePalindrome(string s) {
        map<char, int> m;
        for(char c: s) {
            m[c]++;
        }
        int isFirstTime = true;
        for(auto p: m){
            if(p.second % 2 != 0) {
                if(isFirstTime) {
                    isFirstTime = false;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *