#2309

Greatest English Letter in Upper and Lower Case

newbie · 270 · lc easy +19 · verified · 71.9% accepted · 524 likes · top 81%

Description

Given a string of English letters s, return the greatest letter (in uppercase) that appears in s in both lowercase and uppercase forms. Return an empty string if no such letter exists.

A letter b is greater than letter a when it appears later in the English alphabet.

Example 1:

Input: s = "lEeTcOdE"
Output: "E"
Explanation:
The letter 'E' is the only letter to appear in both lower and upper case.

Example 2:

Input: s = "arRAzFif"
Output: "R"
Explanation:
The letter 'R' is the greatest letter to appear in both lower and upper case.
Note that 'A' and 'F' also appear in both lower and upper case, but 'R' is greater than 'F' or 'A'.

Example 3:

Input: s = "AbCdEfGhIjK"
Output: ""
Explanation:
There is no letter that appears in both lower and upper case.

Code

1
2
3