Matching Tail Pair
This is good practice for finding a short substring inside a larger string. Write a function last2 that takes the last two characters of the string s and counts how many times the same pair appears earlier in the string. Do not count the final occurrence itself, because it is the ending you are comparing against.
Примеры
Ввод
"hixxhi"Вывод
1Ввод
"xaxxaxaxx"Вывод
1Ввод
"axxxaxaxx"Вывод
2Нужно реализовать
def last2(s: str) -> int:
Теги
strings
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
"hixxhi"Expected
12
Input
"xaxxaxaxx"Expected
13
Input
"axxxaxaxx"Expected
24
Input
"xx"Expected
05
Input
"13121311"Expected
06
Input
"a"Expected
0Focus radio
Paused · SomaFM · Fluid