java solution O(n) simple and easy soln
```class Solution {\n    public int longestPalindrome(String[] words) {\n        HashMap map=new HashMap<>();\n        for(int i=0;i key=map.keySet();\n        
```class Solution {\n    public int longestPalindrome(String[] words) {\n        HashMap<String,Integer> map=new HashMap<>();\n        for(int i=0;i<words.length;i++){\n            map.put(words[i],map.getOrDefault(words[i],0)+1);\n        }\n        Set<String> key=map.keySet();\n        int len=0;\n        int count=0;\n        for(String s:key){\n            String rev=""+s.charAt(1) + s.charAt(0);\n            if(map.get(s)>0){ //not included\n              if(s.charAt(0)==s.charAt(1) && map.get(s)>1){ // same letter all time \n                  len=len+4*(map.get(s)/2);\n              }\n              if(s.charAt(0)==s.charAt(1) && count==0 && map.get(s)>0){ //same letter 1 time\n                  len=len+2;\n                  map.put(s,map.get(s)-1);\n                  count++;\n              }\n              else if(map.containsKey(rev) && s.charAt(0)!=s.charAt(1) && map.get(rev)>0){                       //rev also exist\n                    len=len+(map.get(s)==map.get(rev)?4*map.get(s):4*Math.min(map.get(s),map.get(rev)));\n                    map.put(rev,0);\n                    map.put(s,0);\n              }\n                \n            }\n        }\n        return\xA0len;\n\xA0\xA0\xA0\xA0}\n}
['Java']