Simplest solution using HashSet
Intuition\nIn palindromes with even number of characters each of them must have a pair. We can use HashSet, then add and remove the same character, and at the t
# Intuition\nIn palindromes with even number of characters each of them must have a pair. We can use HashSet, then add and remove the same character, and at the time of removal that will be +2 to our overall length. \n\nIf in the end our set is not empty, no matter how many unique characters will be left over, it can be just "a" or "a, b, c", if we were building the palindrome, we could pick any of them and build the palindrome using that (there\'s no pair for each of them), that\'s why we\'re adding +1 in the end in that case.\n\n# Code\n```\npublic class Solution {\n    public int LongestPalindrome(string s) {\n        var set = new HashSet<char>();\n        var maxLength = 0;\n\n        foreach (var c in s)\n        {\n            if (set.Contains(c))\n            {\n                set.Remove(c);\n                maxLength += 2;\n            }\n            else\n                set.Add(c);\n        }\n\n        return set.Count > 0 ? maxLength + 1 : maxLength;\n    }\n}\n```
['C#']