Skip to content

Commit 8823d05

Browse files
authored
Merge pull request #1 from dukun0825/dukun0825-patch-1
Create ELF
2 parents 036c275 + ebafba7 commit 8823d05

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

2019.11.24/ELF

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public int strStr(String haystack, String needle) {
3+
if (needle.length() ==0 )
4+
return 0;
5+
for (int i = 0;i<haystack.length();i++){
6+
if (haystack.charAt(i) == needle.charAt(0)){
7+
int j =i+1;
8+
int k =1;
9+
for (k =1;k<needle.length()&&j<haystack.length();k++){
10+
if (haystack.charAt(j) == needle.charAt(k))
11+
j++;
12+
else
13+
break;
14+
15+
}
16+
if (k == needle.length())
17+
return i;
18+
}
19+
}
20+
return -1;
21+
}
22+
}

0 commit comments

Comments
 (0)