C++ | 0ms solution | 100% Faster |Easy to Understand
\nclass Solution {\npublic:\n    string greatestLetter(string s) {\n        int visited[26]={0};\n        int visited2[26]={0};\n        for(int i=0;i<s.length(
```\nclass Solution {\npublic:\n    string greatestLetter(string s) {\n        int visited[26]={0};\n        int visited2[26]={0};\n        for(int i=0;i<s.length();i++)\n        {\n            if(\'a\'<=s[i] &&s[i]<=\'z\')\n            {\n                visited[s[i]-\'a\']++;\n            }\n                \n            else if(\'A\'<=s[i] &&s[i]<=\'Z\')\n            {\n                visited2[s[i]-\'A\']++;\n            }\n        }\n        int ans=0;    \n        bool flag=false;\n        for(int i=0;i<26;i++)\n        {\n            if(visited[i]>0 &&visited2[i]>0)\n            {\n                ans=i;\n                flag=true;\n            }\n        }\n        string res;\n        if(flag==true)\n            res.push_back(ans+\'A\');\n        return res;\n    }\n};\n```
['C']