Skip to content

Commit 01f597a

Browse files
author
Divyansh Saxena
committed
now build failed error resolved 2
1 parent 8ab930d commit 01f597a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static List<Integer> search(String text, String pattern, int q) {
3939

4040
// h = pow(ALPHABET_SIZE, m-1) % q
4141
for (i = 0; i < m - 1; i++) {
42-
h = (h * ALPHABET_SIZE) % q;
42+
h = h * ALPHABET_SIZE % q;
4343
}
4444

4545
for (i = 0; i < m; i++) {
@@ -61,11 +61,11 @@ public static List<Integer> search(String text, String pattern, int q) {
6161
}
6262

6363
if (i < n - m) {
64-
t = (t - (text.charAt(i) * h) % q);
64+
t = (t - text.charAt(i) * h % q);
6565
if (t < 0) {
6666
t += q;
6767
}
68-
t = (t * ALPHABET_SIZE) % q;
68+
t = t * ALPHABET_SIZE % q;
6969
t = (t + text.charAt(i + m)) % q;
7070
}
7171
}

0 commit comments

Comments
 (0)