Count the Number of Special Characters I

Solution Code
class Solution:
    def numberOfSpecialChars(self, word: str) -> int:
        s = set(word)
        return sum(c in s and c.upper() in s for c in string.ascii_lowercase)
Video GuideLeetcode Daily

Time Complexity

O(n + |Σ|)

Space Complexity

O(|Σ|)