java.lang.Object
g2301_2400.s2309_greatest_english_letter_in_upper_and_lower_case.Solution

public class Solution extends Object
2309 - Greatest English Letter in Upper and Lower Case.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;l<strong>Ee</strong>TcOd<strong>E</strong>&rdquo;</p> <p><strong>Output:</strong> &ldquo;E&rdquo;</p> <p><strong>Explanation:</strong></p> <p>The letter &lsquo;E&rsquo; is the only letter to appear in both lower and upper case.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;a<strong>rR</strong>AzFif&rdquo;</p> <p><strong>Output:</strong> &ldquo;R&rdquo;</p> <p><strong>Explanation:</strong></p> <p>The letter &lsquo;R&rsquo; is the greatest letter to appear in both lower and upper case.</p> <p>Note that &lsquo;A&rsquo; and &lsquo;F&rsquo; also appear in both lower and upper case, but &lsquo;R&rsquo; is greater than &lsquo;F&rsquo; or &lsquo;A&rsquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;AbCdEfGhIjK&rdquo;</p> <p><strong>Output:</strong> &quot;&quot;</p> <p><strong>Explanation:</strong> There is no letter that appears in both lower and upper case.</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>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details