Count Substring Occurrences
Z algorithm
Z Algorithm
Very Easy
Ready
Approved
String
75.0% success
3,020 attempts
1s time
256MB memory
1024KB max code
Given 2 Strings \(C,S\). Find the number of occurrences of C in S. Length of S is N, length of C is M.
Input:
Given 2 Strings \(C,S\).
Output:
Print the number of occurrences of C in S.
Constraints:
\(1 \le M \le N \le 10 ^ 5\).
Examples
Input
abc abcabdabc
Output
2
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Loading Editor...