[Python] 1183 ms, faster than 99.57% of Python3 online submissions
Hello,\n\nThis is my first post, feel free to leave some feedbacks.\n\nCreate a HashMap -> check if mirrors exists -> update HashMap\n\n Normal cases "ob" "bo" 
Hello,\n\nThis is my first post, feel free to leave some feedbacks.\n\nCreate a HashMap -> check if mirrors exists -> update HashMap\n\n* **Normal cases "ob" "bo" :**  \nThe idea is to count the frenquency of each word in words and check if its mirror-word exists among the counted words, if so we can can add the length of these two word to the result (which is 4 in total) times the number of their occurences.\nEx : ["ob", "bo", "ob", "bo"] -> {"ob" : 2 , "bo" : 2}\n\tWe get : len("obbo") * minOccurences("ob", "bo") = 4 * 2 = 8\n\n* **Same letter cases "gg" :**\n For special cases such as "gg", it can be placed in the middle of the palindrome ( +2 to the result ) or if there are enough "gg", it can be spreaded in the palindrome.\nEx : ["gg", "gg", "ff", "ff", "gg", "ff"] -> {"gg" : 3, "ff" : 3} \n-> ffggggggff or ggffggffgg (or invert *g-s* and *f-s*)\nIf there are multiple words with two same letters, if one of them has an odd frequency then it can be put in the middle. \nAnd for the rest, to count properly we just do an integer division of the frequency times 4 (*len("gggg")*).\n\nFor the HashMap strucutre we\'ll use the *Counter* object from *collections*.\nWith it we can create special dict in the form of a *{key : frequency}*.\nAnd we\'ll use the *update* method to decrement properly the used words.  \n  \nHappy coding~\n\n*Runtime: 1183 ms, faster than 99.57% of Python3 online submissions for Longest Palindrome by Concatenating Two Letter Words.\nMemory Usage: 38.3 MB, less than 54.28% of Python3 online submissions for Longest Palindrome by Concatenating Two Letter Words.*\n\nWith comments : \n```\nfrom collections import Counter\n\ndef longestPalindrome(words):\n    # creating a hashmap and memory variables\n    C = Counter(words) \n    res = 0\n    middle = False\n    \n    # going through each individual word\n    # C will be updated to avoid second passage use e.g. "cl" "lc"\n    for word in C:\n        # if the word contains the same letters e.g. "gg"\n        if word==word[::-1]:\n            uni = C[word]%2             # can it "be" unique\n            res += (C[word]//2)*4       # properly adding\n            C.update({word: -C[word]})  # updating C\n            \n            # a middle for the palindrome has been found\n            if not middle and uni: middle = True\n            continue # avoid second passage with second if \n        \n        # cases like "ab" "ba"\n        if word[::-1] in C:\n            tmp = min(C[word],C[word[::-1]])\n            res += tmp*4\n            C.update({word:-tmp, word[::-1]:-tmp})\n    \n    # palindrome\'s middle exists "aa", add +2 to res\n    if middle: res+= 2\n        \n    return res\n```\n\nWithout comments : \n```\nfrom collections import Counter\n\ndef longestPalindrome(words):\n    C = Counter(words) \n    res = 0\n    middle = False\n    \n    for word in C:\n        if word==word[::-1]:\n            uni = C[word]%2\n            res += (C[word]//2)*4\n            C.update({word: -C[word]})\n\t\t\t\n            if not middle and uni: middle = True\n            continue\n        \n        if word[::-1] in C:\n            tmp = min(C[word],C[word[::-1]])\n            res += tmp*4\n            C.update({word:-tmp, word[::-1]:-tmp})\n   \n    if middle: res+= 2     \n    return res\n```
['Python']