C++ easy and simple solution without using Hashmap and beats 100%
Intuition\nkeep record of occurances of each character\n# Approach\n1. Every even lenght palindrome have even no of occurances of characters so for even occuran
# Intuition\nkeep record of occurances of each character\n# Approach\n1. Every even lenght palindrome have even no of occurances of characters so for even occurance we add occurance to the lenght as it is.\n2. Every odd length palindrome should have only one odd occurance so if the lenght of string is more than usual then their might be a case where odd  occurance occurs more than once.\n3. so for that case we count every odd occurance by reducing 1 from it which makes it even and palindrome.\n\n![ss.PNG](https://assets.leetcode.com/users/images/7c173ad3-79c1-4f4a-9bac-a00d42330a1e_1717516161.5215702.png)\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int longestPalindrome(string s) {\n        int x,i,sum=0;\n        x = s.size();\n        if(x==1) return 1;\n        vector<int> freq(123,0);\n        bool hasodd = false;\n\n        for(i=0;i<x;i++){ // for keeping occurances of each character in the string\n            freq[s[i]]++;\n        }\n\n        for(i=65;i<123;i++){ //ascii value of A=65\n            if(freq[i]>0 && freq[i]%2==0) sum+=freq[i];\n\n            else if(freq[i]%2 != 0){\n                sum+= freq[i] - 1;\n                hasodd = true;\n            }\n            if(i==90) i=96;\n        }\n        if(hasodd) return sum + 1;\n        return sum;\n    }\n};\n```
['String', 'C++']