mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
41 lines
1.7 KiB
HTML
41 lines
1.7 KiB
HTML
<p>Given a string of English letters <code>s</code>, return <em>the <strong>greatest </strong>English letter which occurs as <strong>both</strong> a lowercase and uppercase letter in</em> <code>s</code>. The returned letter should be in <strong>uppercase</strong>. If no such letter exists, return <em>an empty string</em>.</p>
|
|
|
|
<p>An English letter <code>b</code> is <strong>greater</strong> than another letter <code>a</code> if <code>b</code> appears <strong>after</strong> <code>a</code> in the English alphabet.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "l<strong><u>Ee</u></strong>TcOd<u><strong>E</strong></u>"
|
|
<strong>Output:</strong> "E"
|
|
<strong>Explanation:</strong>
|
|
The letter 'E' is the only letter to appear in both lower and upper case.
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "a<strong><u>rR</u></strong>AzFif"
|
|
<strong>Output:</strong> "R"
|
|
<strong>Explanation:</strong>
|
|
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'.
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 3:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "AbCdEfGhIjK"
|
|
<strong>Output:</strong> ""
|
|
<strong>Explanation:</strong>
|
|
There is no letter that appears in both lower and upper case.
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= s.length <= 1000</code></li>
|
|
<li><code>s</code> consists of lowercase and uppercase English letters.</li>
|
|
</ul>
|