Count Pattern Occurrences — Solution & Editorial
Check every starting position (fine at these limits), or use KMP for O(|T| + |P|). Advance by one after each match so overlaps count.
Complexity: O(|T| · |P|) naive fits; O(|T| + |P|) with KMP
Watch out: Jumping past a whole match after finding one silently misses overlapping occurrences.