Concept Flow - KMP Pattern Matching Algorithm
Build LPS array for pattern
Start matching text and pattern
Compare characters
↩Yes -> Report No -> Repeat compare
First, build the LPS array for the pattern. Then, scan the text comparing characters. On mismatch, use LPS to shift pattern smartly without rechecking matched characters.
