Solution using bitset. C++


  • 0
    Z
    class Solution {
    public:
        int longestPalindrome(string s) {
            bitset<256> b;
            for(auto ch:s) 
                b.flip(ch);
            return s.size() - b.count() + (b.count() > 0);
        }
    };
    

Log in to reply
 

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