C++
class Solution {\npublic:\n    int longestPalindrome(vector& words) {\n        int ans = 0;\n        vector < vector < int >>count(26, vector < int >(26));\n\n 
class Solution {\npublic:\n    int longestPalindrome(vector<string>& words) {\n        int ans = 0;\n        vector < vector < int >>count(26, vector < int >(26));\n\n        for (string w:words)\n        {\n            int i = w[0] - \'a\',  j = w[1] - \'a\';\n            if (count[j][i])\n            {\n                ans += 4;\n                count[j][i]--;\n            }\n            else count[i][j]++;\n        }\n\n        for (int i = 0; i < 26; ++i)\n        {\n            if (count[i][i]) return ans + 2;\n        }\n\n        return ans;\n    }\n};
[]