C++ Using Map, Easy to Understand Solution


  • 0
    K
    bool canPermutePalindrome(string s) {
        map<char,int> resultMap;
        int tag=0;
        for(auto i:s){
            resultMap[i]+=1;
        }
        
        for(auto j: resultMap){
            if(j.second%2 != 0)
                tag++;
        }
        if(tag>1) return false;
        else return true;
    }

Log in to reply
 

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