Ctrl K

Highest Letter in Both Cases

Easy
You get a string text of English letters. Find the letter that appears in text both as lowercase and as uppercase and comes later in the alphabet than any other such letter. Return it in uppercase. If no letter appears in both cases, return the empty string.
Example 1
text='qAwBaQb' → 'Q'

a, b and q all appear in both cases. The latest in the alphabet is q, so the answer is Q.

Example 2
text='zYxW' → ''

No letter appears in both cases, so the answer is the empty string.

Example 3
text='mM' → 'M'
Constraints
  • 1 ≤ len(text) ≤ 1000
  • text consists of lowercase and uppercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsNext Time From the Same Digits MediumSubstring Pairs With One Typo MediumSwapped Initials Names HardEven Vowel and Consonant Pieces MediumMake Letter Counts Equal Hard
loading Python…
Input
text='qAwBaQb'
Expected
'Q'

Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.