Very easy C++ solution


  • 0
    G
        bool canPermutePalindrome(string s) {
            unordered_map<char, int> store;
            int num_of_odd_cnt_chars = 0;
            for (auto c : s) {
                (++store[c] % 2 != 0) ? num_of_odd_cnt_chars++ : num_of_odd_cnt_chars--;
            }
            return num_of_odd_cnt_chars <= 1;
        }
    

Log in to reply
 

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