String find

Can anyone explain time complexity of string find stl in c++

O(n*m) in the worst case, where n= length of string, m=length of string to be found.

1 Like

You can learn string finding stl in c++ from link

– Time Complexity:
T§=C+TP
(I) – The time, T§, taken by a program, P, is the sum of its compile time C
and its run (or execution) time, TP
(I) – Fixed time requirements – Compile time ©, independent of instance characteristics – Variable time requirements – Run (execution) time TP

Haa.I am getting TLE using find.So checking for alternatives to find which can do its operation in an optimized way