Simple C++ Solution
class Solution {\npublic:\n\n    int longestPalindrome(vector& words) {\n        \n        unordered_mapmp;\n        \n        for(int i=0;i0 && mp[words[i]]>0)
class Solution {\npublic:\n\n    int longestPalindrome(vector<string>& words) {\n        \n        unordered_map<string,int>mp;\n        \n        for(int i=0;i<words.size();i++)\n        {\n            mp[words[i]]++;\n        }\n        \n        int count = 0;\n        int odd = false;\n        \n        for(int i=0;i<words.size();i++)\n        {\n            string curr = words[i];\n            reverse(curr.begin(),curr.end());\n          \n            if(mp.find(curr)!=mp.end() && words[i]!=curr && mp[curr]>0 && mp[words[i]]>0)\n            {\n                if(mp[words[i]]==1)\n                    mp.erase(words[i]);\n                else\n                    mp[words[i]]--;\n                \n                if(mp[curr]==1)\n                    mp.erase(curr);\n                else\n                    mp[curr]--;\n                \n                count += 4;\n            }\n            else if(words[i]==curr && mp[words[i]]>0)\n            {\n                int freq = mp[words[i]];\n                if(freq%2)\n                {\n                    if(!odd)\n                    {\n                        count += 2;\n                        odd = true;\n                    }\n                    freq--;\n                }\n                count += (freq*2);\n                mp.erase(words[i]);\n            }\n        }\n        return count;\n    }\n};
['C']