Loading...
Engaged Employer
to test if a string is a substring of another one
Anonymous
s2 is a substring of s1 if the following are true C: strstr(s1,s2) != NULL C++: s1.find(s2) != string::npos Java: s1.indexOf(s1) != -1
int substr(char s[],char d[]) { int j=0,k,l; char c; while((c=s[j++])!='\0') { k=0; if(c==d[k++]) { l=j; while(s[l]==d[k] && d[k]!='\0' && s[l]!='\0' ) { l++; k++; } if(d[k]=='\0') { return j-1; } } } return -1; }
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.