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
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
"xyzzaz"
Expected1
2
Input
"aababcabc"
Expected4
3
Input
"abc"
Expected1
4
Input
"aaa"
Expected0
5
Input
"ab"
Expected0
6
Input
"abcdef"
Expected4
Focus radio
Paused · SomaFM · Fluid