Java || Simple || Beats 100% runtime && 96.17 memory
Intuition\nThis solution iterates through the English letters in reverse order, starting from \'z\' and moving down to \'a\'. For each letter, it checks if both
# Intuition\nThis solution iterates through the **English letters** in reverse order, starting from **\'z\'** and moving down to **\'a\'**. For each letter, it checks if both its lowercase and uppercase versions are present in the input string. The solution returns the first letter that satisfies this condition as the greatest letter that occurs **both in lowercase and uppercase**.\n\n# Approach\nThe approach taken by this solution is quite straightforward. It uses a loop to iterate through the English letters in reverse order. For each letter, it constructs both the `lowercase` and `uppercase` versions using `Character.toString(i)` and `Character.toString(i - 32)`, respectively. It then checks if both of these versions are present in the input string using the `contains()` method. If a letter is found that satisfies this condition, it **returns** **the** **uppercase** **version** of that letter.\n\n# Complexity\n- Time complexity: $$O(1)$$\nThe time complexity of this solution depends on the number of iterations performed by the loop. Since the loop iterates over a constant number of letters (26 letters in the English alphabet), the time complexity is **O(1)**.\n- Space complexity:  $$O(1)$$\nThe space complexity of this solution is also constant. The solution uses a constant amount of additional memory to store the lower and upper strings, and no extra data structures are used. Thus, the space complexity is **O(1)**.\n\n# Code\n```\nclass Solution {\n    public String greatestLetter(String s) {\n\n        for (int i = \'z\'; i >= \'a\'; i--) {\n            String lower = Character.toString(i);\n            String upper = Character.toString(i - 32);\n            if (s.contains(lower) && s.contains(upper)) {\n                return upper;\n            }\n        }\n\n        return "";\n    }\n}\n\n\n```
['Java']