Skip to content

Commit 704035d

Browse files
author
Mrinal Chauhan
committed
fix: updated code to fix errors
1 parent ecedd07 commit 704035d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public static List<Integer> findPatternOccurrences(String text, String pattern)
2424
int patternLength = pattern.length();
2525
// performing z algorithm
2626
for (int i = patternLength + 1; i < zArray.length; i++) {
27-
if (zArray[i] >= patternLength) {
27+
if (zArray[i] == patternLength) {
2828
occurrences.add(i - patternLength - 1);
29+
i += patternLength - 1;
2930
}
3031
}
3132
return occurrences;

0 commit comments

Comments
 (0)