Unique Character Count
This kind of check is useful when you want to measure how much variety a string contains, such as how many different letters or symbols appear in a text. Write a function count_distinct that counts only the unique characters in s. Case matters: "A" and "a" are considered different characters.
Примеры
Ввод
"hello"Вывод
4Ввод
"aaaa"Вывод
1Ввод
"abcABC"Вывод
6Нужно реализовать
def count_distinct(s: str) -> int:
Теги
stringssethashmap
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inVisible tests
1
Input
"hello"Expected
42
Input
"aaaa"Expected
13
Input
"abcABC"Expected
64
Input
""Expected
05
Input
"a b c"Expected
46
Input
"mississippi"Expected
4Focus radio
Paused · SomaFM · Fluid