We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f8bf680 commit e6368f6Copy full SHA for e6368f6
src/task_28/Solution.java
@@ -0,0 +1,26 @@
1
+package task_28;
2
+
3
+public class Solution {
4
5
+ public static void main(String[] args) {
6
+ String haystack = "missis_sippi";
7
+ String needle = "issip";
8
+ System.out.println(strStr(haystack, needle));
9
+ }
10
+ public static int strStr(String haystack, String needle) {
11
+ if (haystack.length() < needle.length()) {
12
+ return -1;
13
14
+ for (int i = 0; i <= haystack.length() - needle.length(); i++){
15
+ int j = 0;
16
+ while (j < needle.length() && haystack.charAt(i + j) == needle.charAt(j)) {
17
+ j++;
18
19
+ if (j == needle.length()) {
20
+ return i;
21
22
23
24
25
26
+}
0 commit comments