Apply KMP

3.6

12 votes
Approved, Very-Easy, String
Problem

Given 2 strings, P and T, find the number of occurrences of P in T.

Input:

First line contains string P, and second line contains the string T.

Output:

Print a single integer, the number of occurrences of P in T.

Constraints:

1|P||T|105

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?