class Solution {
public:
/**
* Returns a index to the first occurrence of target in source,
* or -1 if target is not part of source.
* @param source string to be scanned.
* @param target string containing the sequence of characters to match.
*/
int strStr(const char *source, const char *target) {
// write your code here
int i = 0;
int j = 0;
if(source == NULL || target == NULL) return -1;
int lens = strlen(source);
int lent = strlen(target);
for (i = 0; i < lens - lent + 1; i++) {
for (j = 0; j < lent; j++) {
if (source[i + j] != target[j]) {
break;
}
}
if (j == lent) {
return i;
}
}
return -1;
}
};