Byte Pattern Counter
In low-level work, a file is often treated as a simple list of bytes. Given buffer and pattern, count how many times pattern appears in buffer as a contiguous fragment. Matches may overlap, so after finding one match you cannot simply jump past it. If the pattern is not found, return 0.
Примеры
Ввод
[255, 20, 133, 1, 255, 20, 133], [255, 20, 133]Вывод
2Ввод
[0, 0, 0, 0], [0, 0]Вывод
3Ввод
[1, 2, 3], [4]Вывод
0Нужно реализовать
def memmem_count(buffer, pattern):
Теги
arraylistssliding-window
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterTests12
Visible tests
Test caché 7
Test caché 8
Test caché 9
Test caché 10
Test caché 11
Test caché 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