C# Three version. With explanation. Fast and simple.
My third version of solving this task.\nThe quickest one ( > 90 % ) and without creating any additional objects like StringBuilder, List of chars, etc...\n\nNee
### My third version of solving this task.\nThe quickest one **( > 90 % )** and without creating any additional objects like StringBuilder, List of chars, etc...\n\nNeed to find the greatest upper case letter which appears in its lowercase version in string.\n\nLetter **\'A\'** goes with code 65 and symbol **\'@\'** has code 64 in ASCII table,   \nso in ASCII table codes symbol **\'@\'** goes "before" letter **\'A\'**,  \n that\'s why **@ < A**.\n\nThen we check all chars in string. We look for such char, that satisfies three conditions:\n- is it upper case?\n- is string contains this upper case char when we convert it to lower case?\n- is this upper char greater, than that char ch (remember, at first ch equals \'@\', so any letter is greater then it).\n\nFinally, we just convert to string this char ch, if it satisfies all those condition. If it stays equals \'@\', we just return empty string.\n\n```\npublic class Solution {\n       \n    public string GreatestLetter(string s)\n    {\n        char ch = \'@\';\n        foreach (char c in s)\n        {\n            if (Char.IsUpper(c) && s.Contains(Char.ToLower(c)) && c > ch)\n                ch = c;\n        }\n        return ch == \'@\' ? "" : ch.ToString() ;\n    }\n}\n```\n\n### Thoughts \n(slow, takes a lot of place, but works of course)\n\n**Don`t do this**\n\n```\npublic class Solution {\n   \n    List<char> chars = new List<char>();\n    \n    public string GreatestLetter(string s)\n    {\n        chars.Clear();\n        chars.AddRange(s.ToCharArray());\n        chars.Sort();\n        char res = \'1\';\n        int count = 0;\n        foreach (char c in chars)\n        {\n            if (Char.IsLower(c))\n                break;\n            count++;\n        }\n        for (int i = 0; i < count; i++)\n        {\n            if (s.Contains(Char.ToLower(chars[i])))\n                res = chars[i];\n        }\n        return res == \'1\' ? "" : res.ToString();\n    }\n}\n```\n-----\n\n**Also definitely not worth do this**\n\n```\npublic class Solution {\n    List<char> listUp = new List<char>();\n    List<char> listLow = new List<char>();\n    List<char> res = new List<char>();\n    \n    public string GreatestLetter(string s)\n    {\n        listUp.Clear();\n        listLow.Clear();\n        res.Clear();\n        \n        foreach (char c in s)\n        {\n            if(Char.IsUpper(c))\n                listUp.Add(c);\n            else\n                listLow.Add(c);\n        }\n        foreach (char c in listUp)\n        {\n            if(listLow.Contains(Char.ToLower(c)))\n                res.Add(c);\n        }\n        res.Sort();\n        return res.Count > 0 ? res[^1].ToString() : "";\n    }\n}\n```
['C#']