JAVA || EASY APPROACH || WITH EXPLAINATION
IF YOU LIKE THE SOLUTION \nPLEASE MAKE SURE TO UPVOTE IT !\n\nWELCOME YOU ALL IN COMMENTS FOR ANY THOUGHTS REGARDING SOLUTION .\n\n\nclass Solution {\n    // SP
IF YOU LIKE THE SOLUTION \nPLEASE MAKE SURE TO UPVOTE IT !\n\nWELCOME YOU ALL IN COMMENTS FOR ANY THOUGHTS REGARDING SOLUTION .\n\n```\nclass Solution {\n    // SPACE COMP :-> O(N) for hashMap\n    // TIME COMP  :-> O(N) for traversing it.\n    public int longestPalindrome(String[] words) {\n        //len to count the length of longest palindrome !\n        int len = 0;\n        // Map to store string with it\'s value of repetions.\n        HashMap<String,Integer> map = new HashMap<>();\n        //Fill the hashMap, if it is repetead increase it by 1.\n        for(String s : words)\n            map.put(s,1+ map.getOrDefault(s,0));\n        \n        boolean found = true;\n        \n        //Traverse through map\n        for(Map.Entry m : map.entrySet()){\n            // Take the string and reverse it , search for reverse string in hashmap\n            String str = (String)m.getKey();\n            String rev = String.valueOf(str.charAt(1)) + String.valueOf(str.charAt(0));\n            \n            /* System.out.println("str : " + str + " rev : " + rev); */\n            \n            if(str.charAt(1) != str.charAt(0) && map.containsKey(rev)){\n                // Make sure their count is greater than zero.\n                if(map.get(str) > 0 && map.get(rev) > 0){\n                    // Take the min of count from both words str and rev.\n                    int min = Math.min(map.get(str),map.get(rev));\n                    // Update the value by subtracting min \n                    map.put(str,map.getOrDefault(str,0) - min);\n                    map.put(rev,map.getOrDefault(rev,0) - min);\n                    // Increase the length by 4 * min\n                    len += 4*min;\n                   /* System.out.println("len :"+ len); */\n                }\n                // If both the characters are same in a string and their count is even \n                //We divide count by 2 so that we can put half half part on both sides and multiply by 4 to increase it corresponding length\n            }else if(str.charAt(1) == str.charAt(0)){\n                len += (map.get(str)/2) * 4;\n                // If count is odd we just wanna use that word once so increase length by 2 only. \n                if(map.get(str)%2 != 0 && found){\n                    found = false; len += 2;\n                }\n                /* System.out.println("len :"+ len); */\n                \n            }\n        }\n        //Finally return the ans.\n        return len;\n    }\n}\n\n/*\n  * DRY RUN\n  // Input : \n     ["lc","cl","lc","cl","gg","gg"]\n     \n    : ->\n        str : gg rev : gg\n        len :4\n        str : lc rev : cl\n        len :12\n        str : cl rev : lc\n     \n  // OUTPUT :\n      12\n      \n      // Input : \n     ["cc","ll","xx"]\n     \n    : ->\n        str : cc rev : cc\n        len :2\n        str : ll rev : ll\n        len :2\n        str : xx rev : xx\n        len :2\n     \n  // OUTPUT :\n      2\n  \n*/\n```
['Java']