Skip to content

Commit ce0594b

Browse files
author
Mrinal Chauhan
committed
fix: updated code to fix errors
1 parent 3c54c1d commit ce0594b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/thealgorithms/strings/Zalgorithm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public static List<Integer> findPatternOccurrences(String text, String pattern)
2323
List<Integer> occurrences = new ArrayList<>();
2424
int patternLength = pattern.length();
2525

26-
for (int i = 0; i < zArray.length; i++) {
27-
if (zArray[i] == patternLength) {
26+
for (int i = patternLength + 1; i < zArray.length; i++) {
27+
if (zArray[i] >= patternLength) {
2828
occurrences.add(i - patternLength - 1);
2929
}
3030
}

0 commit comments

Comments
 (0)