Daily Leetcode Solution
\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n        map<string,int> mp;\n        int n=words.size();\n        for(int i=0;i
```\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n        map<string,int> mp;\n        int n=words.size();\n        for(int i=0;i<n;i++)\n        {\n            mp[words[i]]++;\n        }\n        int ans=0;\n        bool flag=false;\n        int palindromicStrings=0;\n        for(auto &i:mp)\n        {\n            string str=i.first;\n            if(str[0]==str[1])\n            {\n                if(mp[str]%2)\n                {\n                    flag=true;\n                    palindromicStrings+=(mp[str]-1);\n                }\n                else\n                {\n                    palindromicStrings+=mp[str];\n                }\n                mp.erase(str);\n            }\n            else\n            {\n                string rev=str;\n                reverse(rev.begin(),rev.end());\n                if(mp.find(rev)!=mp.end())\n                {\n                    ans=ans+min(mp[rev],mp[str])*4;\n                    mp.erase(rev);\n                    mp.erase(str);\n                }\n            }\n        }\n        if(flag)\n        {\n            return ans+palindromicStrings*2+2;\n        }\n        else\n        {\n            return ans+palindromicStrings*2;\n        }\n    }\n};\n```
['String', 'C']