2309. Greatest English Letter in Upper and Lower Case
Содержание
class Solution:
def greatestLetter(self, s: str) -> str:
mask1 = mask2 = 0
for c in s:
if c.islower():
mask1 |= 1 << (ord(c) - ord("a"))
else:
mask2 |= 1 << (ord(c) - ord("A"))
mask = mask1 & mask2
return chr(mask.bit_length() - 1 + ord("A")) if mask else ""