Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sgfsdfgsdfhgsfhdfhj/489a79838f7e0a5c2ffd086e3458f9b2 to your computer and use it in GitHub Desktop.
Save sgfsdfgsdfhgsfhdfhj/489a79838f7e0a5c2ffd086e3458f9b2 to your computer and use it in GitHub Desktop.
/*
удалил чтоб не позорится перед случайно зашедшими по ссылке
*/
//
public int StrStr(char[] str, char[] pat) {
if (str == null || pat == null)
return -1;
int strlen = str.length;
int plen = pat.length;
if (strlen < plen)
return -1;
int end = strlen - plen;
for (int i = 0; i <= end; i++) {
int j = 0;
for (j = 0; j < plen && str[i + j] == pat[j]; j++) {
}
;
if (j == plen) {
return i;
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment