-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverseLL.java
More file actions
34 lines (26 loc) · 828 Bytes
/
reverseLL.java
File metadata and controls
34 lines (26 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Solution23 {
public int strStr(String haystack, String needle) {
if(haystack.length() < needle.length()){
return -1 ;
}
for (int i = 0; i < haystack.length(); i++) {
if(haystack.charAt(i) == needle.charAt(0)){
boolean find = true;
for (int j = 1 ; j < needle.length(); j++) {
if(haystack.charAt(i+j) != needle.charAt(j)){
find = false;
break;
}
}
if(find){
return i;
}
}
}
return -1;
}
}
public class reverseLL {
public static void main(String[] args) {
}
}