← 返回 microsoft 的题目列表Count letters
类型:online_judge
You are given a string letters made of N English letters. Count the number of different letters that appear in both uppercase and lowercase where all lowercase occurrences of the given letter appear before any uppercase occurrence.
For example, for letters = "aaAbcCABc", the answer is 2. The condition is met for letters "a" and "b", but not for "c".
Write a function:
def solution(letters):
that, given a string letters, returns the number of different letters fulfilling the condition described above.
Examples:
Given letters = "aaAbcCABc", the function should return 2.
Given letters = "zyxZYXzABc", the function should return 6.
Given letters = "ABcdefABcdef", the function should return 0.
Constraints:
N is an integer within the range [1..100,000].
letters is made only of letters a–z and A–Z.
Example
Input
aaAbcCABc