Skip to content

Commit ac52149

Browse files
authored
26October 2023
1 parent 0a8e8eb commit ac52149

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Runtime 0ms
2+
Beats 100.00%
3+
4+
5+
Memory 40.28MB
6+
Beats 72.78%
7+
8+
9+
class Solution{
10+
public int strStr(String str, String sub){
11+
int n1 = str.length();
12+
int n2 = sub.length();
13+
for (int i = 0; i <= n1 - n2; i++){
14+
if (str.substring(i, i + n2).equals(sub)){
15+
return i;
16+
}
17+
}
18+
return -1;
19+
}
20+
}

0 commit comments

Comments
 (0)