I cannot understand KMP, but found Boyer Moore Algorithm – Bad Character Heuristic is very easy to understand and implemented.

```
class Solution {
public:
int strStr(string haystack, string needle) {
if (haystack == needle) return 0;
if (needle.empty()) return 0;
int m = haystack.size();
int n = needle.size();
if (m < n) return -1;
vector<int> bmt(256, -1);
for (int i=0; i<n; ++i) {
bmt[needle[i]] = i;
}
int skip;
for (int i=0; i<=m-n; i += skip) {
skip = 0;
for (int j=n-1; j>=0; --j) {
if (haystack[i+j] != needle[j]) {
skip = max(1, j-bmt[haystack[i+j]]);
break;
}
}
if (skip == 0) return i;
}
return -1;
}
};
```