# Letters Appearing in Both Cases
Given a string `word`, call an English letter special when both its lowercase form and its uppercase form occur somewhere in the string.
Return the number of distinct special letters. Occurrence counts and the order of the two cases do not affect whether a letter is special.
### Examples
**Example 1**
```text
Input: word = "ZzzaAbB"
Output: 3
```
The letters `z`, `a`, and `b` each appear in both cases. The repeated lowercase `z` does not add another special letter, and uppercase `Z` may occur before lowercase `z`.
**Example 2**
```text
Input: word = "aBBccD"
Output: 0
```
Letters `a` and `c` appear only in lowercase, while `b` and `d` appear only in uppercase. Repeating a character in one case does not satisfy the other-case requirement.
### Constraints
- `1 <= word.length <= 50`.
- `word` contains only lowercase and uppercase English letters.
### Clarifying Questions
- Are occurrences counted, or distinct letters? Count distinct letters satisfying the condition.
- Must the lowercase occurrence come first? No; either case may appear first.
- Must the two cases be adjacent? No; they may occur anywhere.
- Can many occurrences of one case compensate for the missing other case? No.
### C++ Interface
```cpp
class Solution {
public:
int numberOfSpecialChars(string word) {
}
};
```
### Reasoning Checkpoints
- Apply the both-cases condition to each distinct English letter.
- Handle repeated occurrences and either ordering of the two cases.
- Justify the final count and resource use under the full input bounds.
```hint Record whether each case appears
Keep separate presence flags for the 26 lowercase and 26 uppercase letters. After scanning the word, count a letter once when both corresponding flags are set.
```
Overview: Count distinct English letters that appear in both lowercase and uppercase, regardless of order or repeated occurrences.
Given a string word, call an English letter special when both its lowercase form and its uppercase form occur somewhere in the string.
Return the number of distinct special letters. Occurrence counts and the order of the two cases do not affect whether a letter is special.
Examples
Example 1
Input: word = "ZzzaAbB"
Output: 3
The letters z, a, and b each appear in both cases. The repeated lowercase z does not add another special letter, and uppercase Z may occur before lowercase z.
Example 2
Input: word = "aBBccD"
Output: 0
Letters a and c appear only in lowercase, while b and d appear only in uppercase. Repeating a character in one case does not satisfy the other-case requirement.
Constraints
1 <= word.length <= 50
.
word
contains only lowercase and uppercase English letters.
Clarifying Questions Guidance
Are occurrences counted, or distinct letters? Count distinct letters satisfying the condition.
Must the lowercase occurrence come first? No; either case may appear first.
Must the two cases be adjacent? No; they may occur anywhere.
Can many occurrences of one case compensate for the missing other case? No.
C++ Interface
class Solution {
public:
int numberOfSpecialChars(string word) {
}
};
Reasoning Checkpoints
Apply the both-cases condition to each distinct English letter.
Handle repeated occurrences and either ordering of the two cases.
Justify the final count and resource use under the full input bounds.