C++ || Naive approach explained || Day 3 Daily Challenge
\nint longestPalindrome(vector<string>& words) {\n        \n        map<string,int> m,mp;\n        //For unequal strings\n        for(auto i:words) {\n         
```\nint longestPalindrome(vector<string>& words) {\n        \n        map<string,int> m,mp;\n        //For unequal strings\n        for(auto i:words) {\n            if(i[0]!=i[1]) {\n                m[i]++; \n            }\n        }\n        //For equal strings\n        for(auto i:words) {\n            if(i[1]==i[0]) {\n                mp[i]++;\n            }\n        }\n        \n        int ans = 0;\n        for(auto i:m) {\n            string s = i.first;\n            swap(s[0],s[1]);\n            //Check if a string and its reverse is present\n            //If yes then increment the less count\n            if(m[s]>0)\n                ans+=min(m[s],i.second)*2;\n        }\n        //Only one odd count is allowed to make palindrome\n        bool flag = false;\n        for(auto i:mp) {\n            if(i.second&1) {\n                flag = true;\n                break;\n            }\n        }\n        //In order to make palindrome, consider only one odd pair\n        if(flag) ans+=2;\n        for(auto i:mp) {\n            //if aa occurs 3 times, we need to consider only 2 occ.\n            if(i.second&1)\n                ans+=(i.second-1)*2;\n           // if aa occurs 2 times, take all occ.\n            else \n                ans += i.second*2;\n        }\n        m.clear(); mp.clear();\n        return ans;\n    }\n```
['String', 'Greedy', 'C']