C# HashSet solution
Time complexity: O(n)\nSpace complexity: O(1)\n\npublic class Solution {\n    public int LongestPalindrome(string s) {\n        \n        if(s == null || s.Leng
Time complexity: O(n)\nSpace complexity: O(1)\n```\npublic class Solution {\n    public int LongestPalindrome(string s) {\n        \n        if(s == null || s.Length == 0)\n            return 0;\n        \n        int len = 0;\n        HashSet<char> set = new HashSet<char>();\n        foreach(char c in s)\n        {\n            if(set.Contains(c))\n            {\n                len += 2;\n                set.Remove(c);\n            }\n            else\n                set.Add(c);\n        }\n        \n        return set.Count > 0? len + 1 : len;\n    }\n}\n```
[]