Skip to content

Commit 2416061

Browse files
authored
Update BoyerMoore.java
1 parent a448bfb commit 2416061

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/com/thealgorithms/searches/BoyerMoore.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.thealgorithms.searches;
22

33
/**
4-
* Boyer-Moore string search algorithm
4+
* Boyer-Moore string search algorithm.
55
* Efficient algorithm for substring search.
66
* https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm
77
*/
@@ -13,7 +13,7 @@ public class BoyerMoore {
1313

1414
public BoyerMoore(String pat) {
1515
this.pattern = pat;
16-
this.R = 256;
16+
this.R = 256;
1717
this.right = new int[R];
1818

1919
for (int c = 0; c < R; c++) {
@@ -26,7 +26,9 @@ public BoyerMoore(String pat) {
2626
}
2727

2828
public int search(String text) {
29-
if (pattern.isEmpty()) return 0;
29+
if (pattern.isEmpty()) {
30+
return 0;
31+
}
3032

3133
int m = pattern.length();
3234
int n = text.length();
@@ -42,9 +44,11 @@ public int search(String text) {
4244
break;
4345
}
4446
}
45-
if (skip == 0) return i;
47+
if (skip == 0) {
48+
return i;
49+
}
4650
}
47-
return -1;
51+
return -1;
4852
}
4953

5054
public static int search(String text, String pattern) {

0 commit comments

Comments
 (0)