Pattern occurrence count

Write codeMedium13 min

Your task

Count how many times a pattern occurs in a text when overlapping occurrences count separately. The pattern is non-empty; either string may otherwise be anything. For example, 'aa' occurs 4 times in 'aaaaa' (starting at indexes 0, 1, 2, and 3), and 'aba' occurs 3 times in 'abababa'.

Examples

count_overlapping(text: str, pattern: str) -> int
Example 1
Inputcount_overlapping("aaaaa", "aa")
Output4