Java | O(N) easy solution
\nclass Solution {\n\n    public int longestPalindrome(String[] words) {\n        HashMap<String, Integer> map = new HashMap<>();\n        int max = 0;\n       
```\nclass Solution {\n\n    public int longestPalindrome(String[] words) {\n        HashMap<String, Integer> map = new HashMap<>();\n        int max = 0;\n        for (int i = 0; i < words.length; i++) {\n            String rev = words[i].charAt(1) + "" + words[i].charAt(0);\n            if (map.containsKey(rev)) {\n                max += 4;\n                map.put(rev, map.get(rev) - 1); // decrease its count as we won\'t be taking it again\n                if (map.get(rev) == 0) map.remove(rev);\n                continue; // as we also won\'t be taking current string again\n            }\n            map.put(words[i], map.getOrDefault(words[i], 0) + 1);\n        }\n        for (String k : map.keySet()) {\n            if (map.get(k) == 1 && (k.charAt(1) + "" + k.charAt(0)).equals(k)) {\n                max += 2;\n                break;\n            }\n        }\n        return max;\n    }\n}\n```\n
[]