Last active
June 12, 2016 22:25
-
-
Save sgfsdfgsdfhgsfhdfhj/489a79838f7e0a5c2ffd086e3458f9b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
удалил чтоб не позорится перед случайно зашедшими по ссылке | |
*/ | |
// | |
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