C++ | O(n) S(1) | 0ms faster than 100%
Runtime: 0 ms, faster than 100.00% of C++ online submissions for Greatest English Letter in Upper and Lower Case.\nMemory Usage: 6.5 MB, less than 91.00% of C++
Runtime: 0 ms, faster than 100.00% of C++ online submissions for Greatest English Letter in Upper and Lower Case.\nMemory Usage: 6.5 MB, less than 91.00% of C++ online submissions for Greatest English Letter in Upper and Lower Case.\n\n```\nclass Solution \n{\npublic:\n    string greatestLetter(const string& s) \n    {\n        std::vector<int> freq(128, 0);\n        for (const char& c : s)\n        {\n            freq[c]++;\n        }\n        \n        for (char c = \'Z\'; c >= \'A\'; c--)\n        {\n            if (freq[c] && freq[(c | 32)])\n                return std::string(1, c);\n        }\n        \n        return "";\n    }\n};\n```
[]