Hashmap  |  One Pass  O(n)  soln  |  C + +
\n# Approach\n Describe your approach to solving the problem. \nlets say we have two strings that are reverse of each other , Now if we have a palindrome and we
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nlets say we have two strings that are reverse of each other , Now if we have a palindrome and we add one string at front and other at back, it will still be a palindrome (len += 4 in our case) Also if all the pairs are used , we can still increase length by putting a string in between if both the char of string should be same. \n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n) (hashmap)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n*PS. This exact question was asked in an amazon interview.*\n# Code\n```\n  int res = 0;\n       unordered_map<string,int> hm; \n       \n       for(string s:words){ // match to make pairs that can be taken in palindrome\n           string p = s;\n           reverse(p.begin(),p.end());\n           if(hm[p]>0){ // reverse of current string found, these 2 strings can be added to palindrome \n               res+= 4;\n               hm[p]--;  // remove occurence of string as we used it for palindrome\n           }\n           else{\n               hm[s]++;   // reverse not fount , put it in hashmap\n           }\n       }\n         //***** to take element at the center with both letters same\n       for(auto i:hm){   // only strings with frequency 1 are left now  \n           if(i.first[0]==i.first[1] && i.second>0){ // to place in center of palindrome we needs chars to be same\n               return res+2;   \n           }\n       }\n\n       return res;\n```
['Hash Table', 'C++']