C++ | Beginner Friendly Solution
Approach\nBasically we can think of these situations:\n[lc, cl, gg] here lc is there and its inverse is also there so we can take lc, cl .. hence count += 4 ...
# Approach\nBasically we can think of these situations:\n[lc, cl, gg] here lc is there and its inverse is also there so we can take lc, cl .. hence count += 4 ..... then we have gg then we can place this in center hence count += 2\n\n# Code\n```\nclass Solution {\npublic:\n    int longestPalindrome(vector<string>& words)\n    {\n        unordered_map<string, int> m;\n        bool flag = true;\n        for (auto &&i : words)\n        {\n            m[i]++;\n        }\n        int ans(0);\n        for (int i = 0; i < words.size(); i++)\n        {\n            string rev = words[i];\n            reverse(words[i].begin(), words[i].end());\n            if (rev != words[i] and m[words[i]] > 0 and m[rev] > 0)\n            {\n                ans += 4;\n                m[words[i]]--, m[rev]--;\n            }\n            else if (rev == words[i] and m[rev] > 1)\n            {\n                ans += 4;\n                m[words[i]] -= 2;\n            }\n            else if (rev == words[i] and flag and m[rev] > 0)\n            {\n                ans += 2;\n                m[rev]--;\n                flag = false;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']