Count the Number of Special Characters I - Problem
You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word.
Return the number of special letters in word.
Input & Output
Example 1 — Mixed Case Letters
$
Input:
word = "aaAbcBC"
›
Output:
3
💡 Note:
Letters 'a', 'b', and 'c' each appear in both lowercase and uppercase forms
Example 2 — Only Lowercase
$
Input:
word = "abc"
›
Output:
0
💡 Note:
All letters are lowercase only, no uppercase versions present
Example 3 — Partial Match
$
Input:
word = "abBcab"
›
Output:
1
💡 Note:
Only letter 'b' appears in both cases (lowercase 'b' and uppercase 'B')
Constraints
- 1 ≤ word.length ≤ 1000
- word consists of only lowercase and uppercase English letters.
Visualization
Tap to expand
Understanding the Visualization
1
Input String
String with mixed case letters
2
Identify Pairs
Find letters existing in both forms
3
Count Result
Return count of special letters
Key Takeaway
🎯 Key Insight: Use sets to efficiently track which letters appear in both lowercase and uppercase forms
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code