Simple C++ by unordered_map in 9 ms


  • 0
    J
        int res = 0;
        unordered_map<char,int> map;
        for(char c:s)
            map[c]++;
        for(int i=0; i<map.size(); ++i) 
            res += (map[i]/2)*2;
        return res==s.size()?res:res+1;

Log in to reply
 

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