C++ | Hashing | Easy to understand | O(n) TC
Key observation here is for making a palindrome with 2 words one of them should be reverse of the other. So use a hashmap and store the frequencies of string x 
Key observation here is for making a palindrome with 2 words one of them should be reverse of the other. So use a hashmap and store the frequencies of string x and when you find a string y which is exactly reverse of any x present in map, pair it with one of them and decrease the count of x by 1 and increase the answer by 4. at last if you iterate through remaining strings in map and find a srting with both chars same like "aa" or "bb"....  You can put this in the middle hence increasing your answer by 2.\n\n```\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n        map<string,int>mp;\n        long long ans=0;\n        for(string x:words){\n            string y=x;\n            reverse(y.begin(),y.end());\n            if(mp.find(y)!=mp.end()){\n                ans+=4;\n                mp[y]--;\n                if(mp[y]==0){\n                    mp.erase(y);\n                }\n                \n            }else{\n                mp[x]++;\n            }\n        }\n        for(auto x:mp){\n            if(x.first[0]==x.first[1]){\n                ans+=2;\n                break;\n            }\n        }\n        \n        \n        return ans;\n        \n    }\n};\n```\nGive a thumps up if you liked the Solution.
['C']