Python || counter || explanation
Upvote if u like\n\n1. Count occurance of all characters\n2. If character occurs even times , add their count\n3. If character occurs odd times , add count-1 an
***Upvote if u like***\n\n1. Count occurance of all characters\n2. If character occurs even times , add their count\n3. If character occurs odd times , add count-1 and make oddFlag=1\n4. Palindrom can maximum have one odd occurance, at middle , so if oddFlag=1 return ans+1\n\n\n```\nclass Solution:\n    def longestPalindrome(self, s: str) -> int:\n        oddFlag=0\n        \n        count=collections.Counter(s)\n\n        ans=0\n        for k,v in count.items():\n            if v%2==1:\n                ans+=v-1\n                oddFlag= 1\n            else:\n                ans+=v\n                \n        if oddFlag == 1:\n            return ans+1\n        return ans\n```\n
['Python', 'Python3']