✅ C++ || With Explanation || Hashmap One Pass ||
Approach :\nIf we have 2 strings that are reverse of each other, then in the main palindrome, we can add one string to the palindrome\'s front and one to its ba
# Approach :\nIf we have 2 strings that are reverse of each other, then in the main palindrome, we can add one string to the palindrome\'s front and one to its back, giving us a count of +4. \n\nIf all the pairs are adopted, we can still add a string to the center, provided both of it\'s letters are same. \n \n Eg. previously : "aylc clya", and we still have a spare string "aa", we can add it to the palindrome as "aylc aa clya", increasing it\'s length by 2. But this can be done only once. \n\n```\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n        int count = 0;\n        unordered_map<string, int> mp;\n        for(int i = 0 ; i < words.size(); i++)\n        {\n            string s = words[i];\n            reverse(s.begin(), s.end());\n            if(mp[s] > 0)\n            {\n                count += 4;\n                mp[s]--;\n            }\n            else\n                mp[words[i]]++;\n        }\n        \n        for(auto i : mp)\n        {\n            if(i.first[0] == i.first[1] and i.second > 0)\n                return count + 2;\n        }\n        return count;   \n    }\n};\n```
['C', 'C++']