Java Hashmap Solution || Easy and intuitive
\n\n# Code\n\nclass Solution {\n    public int longestPalindrome(String[] words) {\n        HashMap<String, Integer> map = new HashMap<>();\n        int ans=0;\
\n\n# Code\n```\nclass Solution {\n    public int longestPalindrome(String[] words) {\n        HashMap<String, Integer> map = new HashMap<>();\n        int ans=0;\n        for(String str : words){\n            String reverse = "" +str.charAt(1) + str.charAt(0);\n\n            if(map.containsKey(reverse)){\n                ans+=4;\n                map.put(reverse, map.get(reverse)-1);\n                if(map.get(reverse)==0){\n                    map.remove(reverse);\n                }\n\n            }\n            else{\n                map.put(str, map.getOrDefault(str,0)+1);\n            }\n           \n\n        }\n         for(char i=\'a\'; i<=\'z\'; i++){\n             String str = ""+i+i;\n             if(map.containsKey(str) && map.get(str)>0){\n                 ans+=2;\n                 break;             }\n         }\n         return ans;\n    }\n\n}\n```
['Java']