Distinct Three-Letter Windows
Think of this as a small window moving across the string and checking three neighboring characters at a time. Write a function count_good_substrings that counts substrings of length 3 where all characters are different. Return the number of good substrings. If the same good substring appears in different positions, count each occurrence separately.
Примеры
Ввод
"xyzzaz"Вывод
1Ввод
"aababcabc"Вывод
4Ввод
"abc"Вывод
1Нужно реализовать
def count_good_substrings(s: str) -> int:
Теги
stringssliding-windowset
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saTests12
Visible tests
Skrytý test 7
Skrytý test 8
Skrytý test 9
Skrytý test 10
Skrytý test 11
Skrytý test 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid