Matching String Pairs
This exercise shows how to compare two strings by small chunks instead of single characters. Write a function string_match that takes strings a and b and counts the positions where both strings have the same two-character substring at the same index. Only check positions where a full two-character slice exists in both strings.
Примеры
Ввод
"xxcaazz", "xxbaaz"Вывод
3Ввод
"abc", "abc"Вывод
2Ввод
"abc", "axc"Вывод
0Нужно реализовать
def string_match(a: str, b: str) -> int:
Теги
stringssliding-window
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
"xxcaazz", "xxbaaz"Expected
32
Input
"abc", "abc"Expected
23
Input
"abc", "axc"Expected
04
Input
"hello", "he"Expected
15
Input
"", ""Expected
06
Input
"zzaacxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Expected
1Focus radio
Paused · SomaFM · Fluid