Matching Two-Character Windows
Imagine comparing two strings with a small window that is always 2 characters wide. Write a function string_match that takes strings a and b and counts the positions where their two-character slices are the same. Only compare positions where both strings have a full two-character slice.
Примеры
Ввод
"xxcaazz", "xxbaaz"Вывод
3Ввод
"abc", "abc"Вывод
2Ввод
"abc", "axc"Вывод
0Нужно реализовать
def string_match(a: str, b: str) -> int:
Теги
strings
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaVisible tests
1
Input
"xxcaazz", "xxbaaz"Expected
32
Input
"abc", "abc"Expected
23
Input
"abc", "axc"Expected
04
Input
"hello", "he"Expected
15
Input
"aabbccdd", "abbbxxd"Expected
16
Input
"", "x"Expected
0Focus radio
Paused · SomaFM · Fluid