C++ string::find complexity
Why the c++’s implemented string::substr() doesn’t use the KMP algorithm (and doesn’t run in O(N + M)) and runs in O(N * M)? I assume you mean find(), rather than substr() which doesn’t need to search and should run in linear time (and only because it has to copy the result into a new string). … Read more