4 lines C++ hash table


  • 0
    class Solution {
    public:
        bool canPermutePalindrome(string s) {
            unordered_map<char, int>m;
            int odd = 0;
            for(auto c: s) (m[c]++ % 2) ? odd-- : odd++;
            return odd <= 1;
        }
    };
    

Log in to reply
 

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