Longest Palindrome
Intuition\nL M R   L -> R\n123  321  middle -> 1 elemnt  -> 6\n12321 -> 5\n\n# Code\n\nclass Solution {\n    public int longestPalindrome(String[] words) {\n   
# Intuition\nL M R   L -> R\n123  321  middle -> 1 elemnt  -> 6\n12321 -> 5\n\n# Code\n```\nclass Solution {\n    public int longestPalindrome(String[] words) {\n        HashMap<String,Integer> hm = new HashMap<>();\n        int ans=0,flag=0;\n        for(int i=0;i<words.length;i++){\n            hm.put(words[i],hm.getOrDefault(words[i],0)+1);\n        }\n        for(String word : hm.keySet()){\n            char ch= word.charAt(0);\n            char ch1= word.charAt(1);\n            int count=hm.get(word);\n            String rev=""+ch1+ch;\n            if(hm.containsKey(rev)){\n                if(ch == ch1){\n                    if(hm.get(word)%2==0){\n                        ans+=hm.get(word)*2;\n                    }\n                    else{\n                        if(flag==0){\n                            ans+=hm.get(word)*2;\n                            flag=1;\n                        }\n                        else{\n                            ans+=(hm.get(word)-1)*2;\n                        }\n                    }\n                }\n                if(ch != ch1) ans+=Math.min(hm.get(word),hm.get(rev))*2;\n \n            }\n \n \n        }\n        return ans;\n    }\n    }\n\n```
['Java']