<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>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;l<strong><u>Ee</u></strong>TcOd<u><strong>E</strong></u>&quot;
<strong>Output:</strong> &quot;E&quot;
<strong>Explanation:</strong>
The letter &#39;E&#39; 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 = &quot;a<strong><u>rR</u></strong>AzFif&quot;
<strong>Output:</strong> &quot;R&quot;
<strong>Explanation:</strong>
The letter &#39;R&#39; is the greatest letter to appear in both lower and upper case.
Note that &#39;A&#39; and &#39;F&#39; also appear in both lower and upper case, but &#39;R&#39; is greater than &#39;F&#39; or &#39;A&#39;.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;AbCdEfGhIjK&quot;
<strong>Output:</strong> &quot;&quot;
<strong>Explanation:</strong>
There is no letter that appears in both lower and upper case.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 1000</code></li>
	<li><code>s</code> consists of lowercase and uppercase English letters.</li>
</ul>

class Solution:
    def greatestLetter(self, s: str) -> str:
        # Create a set to store the characters in the string
        char_set = set(s)
        
        # Initialize a variable to keep track of the greatest letter found
        greatest = ""
        
        # Iterate over the uppercase letters from 'Z' to 'A'
        for char in range(ord('Z'), ord('A') - 1, -1):
            # Check if both the uppercase and lowercase versions of the letter are in the set
            if chr(char) in char_set and chr(char + 32) in char_set:
                # If found, update the greatest letter and break the loop
                greatest = chr(char)
                break
        
        return greatest

# Example usage:
solution = Solution()
print(solution.greatestLetter("lEeTcOdE"))  # Output: "E"
print(solution.greatestLetter("arRAzFif"))  # Output: "R"
print(solution.greatestLetter("AbCdEfGhIjK"))  # Output: ""
31