How to find the maximum number of non-overlapping occurances of a given substring.

Revision en1, by chirag_h, 2021-06-07 12:43:48

I was trying this problem Taklu Kuddus.

The problem gives us a string S and a pattern P and for Q queries we have to find the maximum number of non-overlapping occurrences of P in the substring of S of the given range in q.

I first tried brute force which got TLE. I tried playing with the starting and ending indexes of matched substrings but could not think of a clear strategy.

Any leads on how to approach this?

Tags #string matching, #string

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English chirag_h 2021-06-07 12:43:48 550 Initial revision (published)