题目:
解题思路:
暴力算法
int strStr(char* haystack, char* needle) {
int n = strlen(haystack), m = strlen(needle);
for (int i = 0; i + m <= n; i++) {
bool res = true;
for (int j = 0; j < m; j++) {
if (haystack[j+i] != needle[j]) {
res = false;
break;
}
}
if (res) return i;
}
return -1;
}