class Solution {
public:
char *strStr(char *haystack, char *needle) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
//naive O(mn) solution
if(*needle==NULL||!needle)
return haystack;
char* hs=haystack;
while(*hs){
char* p1=hs;
char* p2=needle;
while(*p1&&*p2&&(*p1==*p2)){
++p1;
++p2;
}
if(*p2==NULL)
return hs;
++hs;
}
return NULL;
}
};