Warner Bros. Discovery may need to count occurrences of a marker in text processed for HBO Max search or content tooling. Given a text string and a pattern string, return how many times the pattern occurs in the text, including overlapping occurrences.
A match starts at every index where the complete pattern equals the corresponding text window. Return 0 when the pattern is empty or does not occur. The input is case-sensitive.
Implement count_pattern_occurrences(text, pattern).
text, a string of length n, and pattern, a string of length m.pattern in text.def count_pattern_occurrences(text, pattern):