File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11package 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 ) {
You can’t perform that action at this time.
0 commit comments