✅C++|| Using Map and Check Reverse  || Easy Solution || Commented Solution
\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n     map<string,int> mp;\n        int len = 0;\n        int ans = 0;\n        b
```\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n     map<string,int> mp;\n        int len = 0;\n        int ans = 0;\n        bool flag = false;\n        \n        //Making a map to store frequency of each word\n        for(auto word: words){\n            mp[word]++;\n        }\n        \n        //Extracting word by word from the map\n        for(auto x: mp){\n            //If the extracted word has same characters\n            if(x.first[0] == x.first[1])\n            {\n                //If the count is odd\n                if(x.second%2 == 1){\n                    flag = true;\n                    len += (x.second-1);\n                }\n                //If the count is even\n                else\n                {\n                    len += mp[x.first];\n                }\n                //Erase that word from the map\n                mp.erase(x.first);\n            }\n            //If the extracted words have different charcters \n            else\n            {\n                string str = x.first;\n                //then reverse it\n                reverse(str.begin(),str.end());\n                \n                //Check if reverse is present in map \n                if(mp.find(str) != mp.end()){\n                    //if present add min*4\n                    ans += min(mp[str],x.second)*4;\n                }\n                //erase both string and its reverse from map\n                mp.erase(str);\n                mp.erase(x.first);\n            }\n        }\n        //If we have got an odd frequency character then we have to add an extra 2 to final answer\n        if(flag == true){\n            return ans + len*2+2;\n        }\n        return ans + len*2;\n    }\n};\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n     map<string,int> mp;\n        int len = 0;\n        int ans = 0;\n        bool flag = false;\n        \n        //Making a map to store frequency of each word\n        for(auto word: words){\n            mp[word]++;\n        }\n        \n        //Extracting word by word from the map\n        for(auto x: mp){\n            //If the extracted word has same characters\n            if(x.first[0] == x.first[1])\n            {\n                //If the count is odd\n                if(x.second%2 == 1){\n                    flag = true;\n                    len += (x.second-1);\n                }\n                //If the count is even\n                else\n                {\n                    len += mp[x.first];\n                }\n                //Erase that word from the map\n                mp.erase(x.first);\n            }\n            //If the extracted words have different charcters \n            else\n            {\n                string str = x.first;\n                //then reverse it\n                reverse(str.begin(),str.end());\n                \n                //Check if reverse is present in map \n                if(mp.find(str) != mp.end()){\n                    //if present add min*4\n                    ans += min(mp[str],x.second)*4;\n                }\n                //erase both string and its reverse from map\n                mp.erase(str);\n                mp.erase(x.first);\n            }\n        }\n        //If we have got an odd frequency character then we have to add an extra 2 to final answer\n        if(flag == true){\n            return ans + len*2+2;\n        }\n        return ans + len*2;\n    }\n};\n```\n**Please upvote if it was helpful for you, thank you!**
['String', 'C']