2 ways | hashSet | Freq Arrays | JAVA
1 - using HashSet\n\t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int longestPalindrome(String s) {\n\t\t\t\t\tif(s==null || s.length()==0) return 0;\n\t\t\t\t\
**1 - using HashSet**\n\t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int longestPalindrome(String s) {\n\t\t\t\t\tif(s==null || s.length()==0) return 0;\n\t\t\t\t\tHashSet<Character> hs = new HashSet<Character>();\n\t\t\t\t\tint count = 0;\n\t\t\t\t\tfor(int i=0; i<s.length(); i++){\n\t\t\t\t\t\tif(hs.contains(s.charAt(i))){\n\t\t\t\t\t\t\ths.remove(s.charAt(i));\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ths.add(s.charAt(i));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(!hs.isEmpty()) return count*2+1;\n\t\t\t\t\treturn count*2;\n\t\t\t  }  \n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n**2 - using Frequency array**\n\t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int longestPalindrome(String s) {\n\t\t\t\t\tint[] freq = new int[128];        \n\t\t\t\t\tfor(char c : s.toCharArray()) {\n\t\t\t\t\t\t++freq[c];\n\t\t\t\t\t}\n\n\t\t\t\t\tint OddGroup = 0;\n\n\t\t\t\t\tfor(int i : freq) {\n\t\t\t\t\t\tOddGroup += i & 1;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn s.length() - OddGroup + (OddGroup > 0 ? 1 : 0);  \n\t\t\t}\n\t\t}
['Java']