Double X Counter
Finding short fragments inside a string is useful in text checks, logs, and simple analyzers. Write a function count_xx that takes a string s and counts how many times the substring xx appears in it. Overlapping matches count too, so xxx contains two such pairs.
Примеры
Ввод
"abcxx"Вывод
1Ввод
"xxx"Вывод
2Ввод
"xxxx"Вывод
3Нужно реализовать
def count_xx(s: str) -> int:
Теги
stringssliding-window
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
"abcxx"Expected
12
Input
"xxx"Expected
23
Input
"xxxx"Expected
34
Input
"abc"Expected
05
Input
""Expected
06
Input
" "Expected
0Focus radio
Paused · SomaFM · Fluid