Substring in a string

example if string is ram substring = am how to check if am is present in ram .

@Vikaspal you can simply use brute forcefor this or use stl

if (s1.find(s2) != string::npos) {     //npos means no position
    cout << "found!" << '\n';
}

@sdevwrat can u explain hte string::npos i m not able to digest it

And also what is the complexity of this substring find.

string::npos is used to check if we got a no position from our string find() means dont get what we are looking for.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.