Greatest English Letter in Upper and Lower Case - Problem
Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists, return an empty string.
An English letter b is greater than another letter a if b appears after a in the English alphabet.
Input & Output
Example 1 — Basic Case
$
Input:
s = "lEeTcOdE"
›
Output:
"E"
💡 Note:
The string contains both 'E' and 'e'. Among all letters that appear in both cases (E, T, C, O, D), E is the greatest alphabetically.
Example 2 — No Valid Letters
$
Input:
s = "arRAzFif"
›
Output:
"R"
💡 Note:
The string contains both 'R' and 'r'. R is the only letter that appears in both uppercase and lowercase forms.
Example 3 — Single Letter Case
$
Input:
s = "AbCdEfGhIjKlMnOpQrStUvWxYz"
›
Output:
""
💡 Note:
Each letter appears only once in either uppercase or lowercase, but never both. No letter appears in both cases.
Constraints
- 1 ≤ s.length ≤ 1000
- s consists of lowercase and uppercase English letters only.
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code