C++ || Frequency Map
Connect with me on LinkedIn: https://www.linkedin.com/in/abhay5349singh/\n\n\nclass Solution {\npublic:\n\n    int longestPalindrome(vector<string>& words) {\n 
**Connect with me on LinkedIn**: https://www.linkedin.com/in/abhay5349singh/\n\n```\nclass Solution {\npublic:\n\n    int longestPalindrome(vector<string>& words) {\n        map<string,int> mp;\n        \n        for(int i=0;i<words.size();i++) mp[words[i]]++;\n        \n        int len=0, extra=false;\n        map<string,int> :: iterator it;\n        for(it=mp.begin();it!=mp.end();it++){\n            string s1=it->first;\n            int f1=it->second;\n            string s2=s1;\n            reverse(s2.begin(),s2.end());\n            \n            if(mp.find(s2)!=mp.end()){ // checking if reverse of current string exist or not\n                int f2=mp[s2];\n                \n                if(s1==s2){\n                    len += (f1>1 ? (f1/2)*4 : 0);\n                    if(f1%2==1) extra=true; // [\'dd\',\'aa\',dd\',\'bb\'] --> we can use 1 of the pair occuring once as mid of our palindrome\n                }else{\n                    len += min(f1,f2)*4;\n                }\n                \n                mp.erase(s2);\n            }\n            mp.erase(s1);\n        }\n        \n        if(extra) len+=2;\n        \n        return len;\n    }\n};\n```\n\n**Do Upvote If it Helps**
['C++']