MicrosoftOA #70
Valid Mixed Case Letters
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Count the distinct English letters that appear in both lowercase and uppercase, where every lowercase occurrence of the letter comes before every uppercase occurrence. Count by letter only.
This site uses a standard input/output protocol.
Input
One line containing a string of English letters of length 1..100000, consisting only of a-z and A-Z.
Output
Output a single integer, the answer.
Example 1
Input:
aaAbBcC
Output:
3
Example 2
Input:
aAaB
Output:
0
Example 3
Input:
ABC
Output:
0
Example notes
Example 1: the lowercase a, b, and c all appear first, so 3 letters count. Example 2: a appears in lowercase again after A, so it does not qualify; b has no lowercase form, for a total of 0. Example 3: every letter appears only in uppercase, so 0.
Editorial
Loading solution…