Python simple kraken ninja covid version
Intuition\n\nPalindromes are made up of pairs of matching characters, with an optional unmatched character in the center of the palindome (e.g. abba or abcba).\
# Intuition\n\nPalindromes are made up of pairs of matching characters, with an optional unmatched character in the center of the palindome (e.g. abba or abcba).\n\n# Approach\n\nUse a set to keep track of unmatched characters. If we encounter a character that is already in our set, we can add this pair to our palindrome (increasing the palindrome\'s length by +2) and remove the single from our set.\n\nIf we have any left over singles at the end, we can use one of them for the center of our palindrome to increase the palindrome length by 1.\n\n# Complexity\n- Time complexity: $O(n)$, since we iterate over each character in the string\n\n- Space complexity: $O(1)$, since the only extra storage we use is the counter for palindrome length and a set that is at most the size of our character set (ASCII, for example).\n\n\n# Code\n```\nclass Solution:\n    def longestPalindrome(self, s: str) -> int:\n        singles = set()\n        length = 0\n\n        for char in s:\n            if char in singles:\n                singles.remove(char)\n                length += 2\n            else:\n                singles.add(char)\n        \n        if len(singles) > 0:\n            length += 1\n        \n        return length\n\n```
['Python3']