✅C++ || ✅Using HashMAP || ✅ Simple String Solution || ✅Short & Easy
Please Upvote If You like It \uD83D\uDE0A\n\n\nclass Solution {\npublic:\n    string greatestLetter(string s) \n    {\n        // declare a Hahmap for storing t
**Please Upvote If You like It \uD83D\uDE0A**\n\n```\nclass Solution {\npublic:\n    string greatestLetter(string s) \n    {\n        // declare a Hahmap for storing the characters and their occurance\n        unordered_map<char, int> mp;\n        \n        // counting occuracne\n        for(auto it: s)\n        {\n            mp[it]++;\n        }\n        \n        // sort the string so repeated char will be come with together\n        sort(s.begin(), s.end());\n        \n        // declare a ans string that will store our ans\n        string ans = "";\n        for(int i=0; i<s.size(); i++)\n        {\n            // char curr chatr into lowercase and uppercase\n            char l = tolower(s[i]);\n            char u = toupper(s[i]);\n            \n            // if both lower and uppercase are present then store it into ans\n            // it will take greatest english letter that have occured more than 1 because it will run till n\n            if(mp[l] && mp[u])\n            {\n                ans = u;        // storeing uppercase as given in the question that we need to return uppercase \n            }     \n        }\n        \n        return ans;\n    }\n};\n```
['String']