Simple solution Using Counter Method Space Complexity O(26+26)  , Time Complexity O(n)
\nclass Solution {\npublic:\n    string greatestLetter(string s) {\n        vector<bool> cntCap(26,false) , cntSml(26,false);\n        int n = s.size();\n      
```\nclass Solution {\npublic:\n    string greatestLetter(string s) {\n        vector<bool> cntCap(26,false) , cntSml(26,false);\n        int n = s.size();\n        for(int i=0;i<n;++i){\n            if(s[i]>=\'a\' && s[i]<=\'z\'){\n                cntSml[s[i]-\'a\']=true;\n            }else{\n                cntCap[s[i]-\'A\']=true;\n            }\n        }\n        \n        string ans = "";\n        \n        for(int i=25;i>=0;--i){\n            if(cntSml[i]==true && cntCap[i]==true){\n                ans.push_back(i+\'A\');\n                break;\n            }\n        }\n        return ans;\n    }\n};\n```
[]