✅ [Python] Simple O(N) Solution || Straightforward
PLEASE UPVOTE if you like \uD83D\uDE01 If you have any question, feel free to ask. \n 2 Key Points\n\t the center word can only contain only two identical lette
**PLEASE UPVOTE if you like** \uD83D\uDE01 **If you have any question, feel free to ask.** \n* 2 Key Points\n\t* the center word can only contain only two identical letters like \'aa\'\n\t\t* for example \'bc**aa**cb\'\n\t\t* palindrome may not contain center word, for example \'bccb\'\n\t* only pairs like (\'aa\', \'aa\') or (\'ab\', \'ba\') can put on two sides respectively\n\t\t* so we count the \'aa\' and \'abba\' patterns\n\t\t* if the count of \'aa\' pattern is odd, the left one can be the center word\n\n```\nclass Solution(object):\n    def longestPalindrome(self, words):\n        wc = collections.Counter(words)\n        aa = 0  # count how many words contain only two identical letters like \'aa\'\n        center = 0  # if one count of \'aa\' is odd, that means it can be the center of the palindrome, answer can plus 2\n        abba = 0 # count how many word pairs like (\'ab\', \'ba\') and they can put on both sides respectively\n\n        for w, c in wc.items():\n            if w[0] == w[1]: # like \'aa\', \'bb\', ...\n                aa += c // 2 * 2 # if there are 3 \'aa\', we can only use 2 \'aa\' put on both sides respectively\n                # if one count of \'aa\' is odd, that means it can be the center of the palindrome, answer can plus 2\n                if c % 2 == 1: center = 2\n            else:\n                abba += min(wc[w], wc[w[::-1]]) * 0.5  # will definitely double counting\n        return aa * 2 + int(abba) * 4 + center\n```
['Python']