Greatest English Letter in Upper and Lower Case

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.

Example 1
Inputs = "lEeTcOdE"
Output"E"
The letter 'E' is the only letter to appear in both lower and upper case.
Example 2
Inputs = "arRAzFif"
Output"R"
The letter 'R' is the greatest letter to appear in both lower and upper case; 'A' and 'F' also appear in both lower and upper case, but 'R' is greater than both.

Constraints

  • 1 <= s.length <= 1000
  • s consists of lowercase and uppercase English letters.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate