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
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięTests12
Visible tests
Ukryty test 7
Ukryty test 8
Ukryty test 9
Ukryty test 10
Ukryty test 11
Ukryty 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