✅ C++ Clean Code O(N) || With Line by Line Explanation
Code:\n\nint longestPalindrome(vector<string>& words) {\n        unordered_map<string, int> mp;\n        int unpaired=0, ans=0; // Unpaired stores number of unp
**Code:**\n```\nint longestPalindrome(vector<string>& words) {\n        unordered_map<string, int> mp;\n        int unpaired=0, ans=0; // Unpaired stores number of unpaired words with both letters same\n        for(string word: words) // Traverse through the array of strings\n        {\n            if(word[0]==word[1]) // If characters are repeating eg: aa, dd, rr, etc\n            {\n                if(mp[word]>0) // If that word already exists in map\n                {\n                    unpaired--; // Decrease as a pair is found\n                    mp[word]--; // Remove that word from map\n                    ans+=4; // Answer increase by 4 bcoz "aa""aa" or "cc""cc" can form pallindrome\n                }\n                else\n                {\n                    mp[word]++; // Add word to map\n                    unpaired++; // Increase number of unpaired numbers with same characters\n                }\n            }\n            else // If characters are not repeating eg: ab, cd, dc, etc \n            {\n                string rev=word;\n                reverse(rev.begin(), rev.end()); // Reverse the string\n                if(mp[rev]>0) //If reverse exists\n                {\n                    ans+=4; //Increase answer as pallindrome can be formed\n                    mp[rev]--; // Remove the word from map\n                }\n                else mp[word]++; // Add word to map \n            }\n        }\n        // If unpaired word with same character exists we can insert it in middle to form a pallindrome\n        // eg: sceaaecs\n        if(unpaired>0) ans+=2; \n        return ans;\n    }\n```\n**Please upvote if it helps!**
['C', 'C++']