DEV Community

Discussion on: The algorithm behind Ctrl + F.

Collapse
 
maowtm profile image
maowtm

KMP is definitely O(m+n) even in worst case, because after the table construction (O(m)) it's just a linear scan on the string (O(n)).

Thread Thread
 
akhilpokle profile image
Akhil

Thanks for sharing! Updated!