C++ solution using hashmap with complete explanation|| Easy to understand
Intuition\nIn palindrome string either all characters occurs even number of times or only one character occurs once and rest occurs even number of times.\n\nTo 
## Intuition\nIn palindrome string either all characters occurs **even** number of times or only **one** character occurs once and rest occurs even number of times.\n\nTo understand it better : In "abccba" all characters are occuring twice and it is palindrome and in  "abcdcba" all characters are occuring twice except d. But it is not possible that two character occur only once in the string to make it palindrome. \n# Approach\nThe first approach that comes to our mind is to create a unordered map. Track the number of times a character is present in string.\nIf a character is present even number of times then all instances of that character can be added in palindrome.\nIf a character is present odd number of times \'n\' then n-1 instances can be added in palindrome. For eg: if a character is present 3 times then 2 instaces of that character can be used in pallindrome.\n\nNow after adding all instances in palindrome, now among all characters which occur odd number of times take only one character.\nFor eg: if a string is given as \'aabbccdefg\' then in palindrome \' \'abc_cba\' either d or e or f or g can occur.  \n\nSo, first run a loop to add the number of times a character has occured using map. Now, run loop again and add the conditions mentioned above accordingly.\n\n\n# Complexity\n- Time complexity: O(n) because no nested loops are present.\n\n- Space complexity:O(n) by unordered map.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int longestPalindrome(string s) {\n        //if(s.length()==1) return 1;\n        unordered_map<char,int>mp;\n        int n=s.length();\n        for(int i=0;i<n;i++){\n            mp[s[i]]++;\n        }\n        int length=0;\n        for(auto i:mp){\n            if(i.second%2==0) length+=i.second;\n            else if(i.second>2 && i.second%2==1) length+=i.second-1;\n        }\n        for(auto i:mp){\n            if(i.second%2==1){\n                length++;\n                break;\n            }\n\n        }\n        return length;\n    }\n};\n```
['Hash Table', 'String', 'C', 'C++']