PATSEARCH Editorial

Problem Statement

You are given two string S and P. You have to tell if string P occurs as a substring in the string S.

Approach

Normally this problem is easy to solve using two loops. But here that will given TLE because of the tight constraints. You can solve this by using KMP Algorithm for Pattern Searching in O(N+M) time.