Valid Mixed Case Letters
You are given a string letters consisting of N English alphabet characters (a-z, A-Z).
Your task is to determine how many distinct alphabet letters appear in both lowercase and uppercase, and all of the lowercase occurrences of that letter appear before any of its uppercase occurrences in the string.
Function Signature
Complete the function solution in the editor.
solution has the following parameter:
String letters: a string of English letters (a-z, A-Z)
Input
• A string letters of length N (1 ≤ N ≤ 100,000)
• The string contains only English letters (a-z, A-Z)
Output
• Return an integer representing the number of distinct letters that satisfy the following:
- Both the lowercase and uppercase forms of the letter appear in the string
- All lowercase occurrences appear before any uppercase occurrence of that letter
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
See above 🐳