1/20
Loading...
🔍KMP Algorithm
Efficient algorithm for finding patterns in text! 🎯 Goal: Find 'ABAB' pattern ⏱️ Time: O(n+m) Key idea: Don't restart from beginning on mismatch, use LPS array to skip!
Loading...
Efficient algorithm for finding patterns in text! 🎯 Goal: Find 'ABAB' pattern ⏱️ Time: O(n+m) Key idea: Don't restart from beginning on mismatch, use LPS array to skip!
The KMP (Knuth-Morris-Pratt) algorithm finds patterns in text by skipping unnecessary comparisons, achieving O(n+m) time. It uses the LPS (Longest Proper Prefix-Suffix) array.