1
2
3
4
5
6
7
8
9
10
11
| class Solution {
public int strStr(String haystack, String needle) {
for(int i = 0; i <= haystack.length() - needle.length(); i++) {
String temp = haystack.substring(i, i + needle.length());
if(temp.equals(needle)) return i;
}
return -1;
}
}
|