409. Longest Palindrome: Java Solution
Input:\n\n\nExplaination:\n\n\n\n\nOutput:\n\n\n\n\n\n\nclass Solution {\n\tpublic int longestPalindrome(String s) {\n\t\tif (s == null || s.length() == 0){\n  
Input:\n![image](https://assets.leetcode.com/users/images/8919988c-16cd-4009-b7d7-ad9db619b0df_1638030155.3362875.png)\n\nExplaination:\n![image](https://assets.leetcode.com/users/images/8077443b-9b38-40ad-b87e-e987dacc960b_1701190922.9944983.png)\n\n\n\nOutput:\n![image](https://assets.leetcode.com/users/images/68f8a0a4-ae4b-421e-aef4-54fe8b63eab5_1701190937.9680054.png)\n\n\n\n\n```\nclass Solution {\n\tpublic int longestPalindrome(String s) {\n\t\tif (s == null || s.length() == 0){\n            return 0;\n        }\n\t\tHashSet<Character> hs = new HashSet<Character>();\n\t\tint count = 0;\n\t\tfor (int i = 0; i < s.length(); i++) {\n\t\t\tif (hs.contains(s.charAt(i))) {\n\t\t\t\ths.remove(s.charAt(i));\n\t\t\t\tcount++;\n\t\t\t} else {\n\t\t\t\ths.add(s.charAt(i));\n\t\t\t}\n\t\t}\n\t\tif (!hs.isEmpty()){\n            return count * 2 + 1;\n        }\n\t\treturn count * 2;\n\t}\n}\n```\n\nIf it helped, please UPVOTE. Happy Coding and keep up the good work.\nFeel free to give your suggestions or correct me in the comments.\nThanks for reading.\uD83D\uDE43
['Java']