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