File tree 1 file changed +9
-2
lines changed
src/main/java/com/thealgorithms/strings 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .strings ;
2
- import java .util .*;
2
+ import java .util .ArrayList ;
3
+ import java .util .List ;
4
+ import java .util .Scanner ;
3
5
4
6
/*
7
+ @author Lohit M Kudlannavar (https://github.com/Lohit-pro)
8
+
5
9
https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm
6
10
The Rabin-Karp algorithm calculates a hash value for the pattern and a hash value for a sliding window
7
11
of text in the same length as the pattern. If the hash values match, it checks character by character
10
14
11
15
public class PatternSearchUsingRabinKarpAlgo {
12
16
17
+ private PatternSearchUsingRabinKarpAlgo () {
18
+ }
19
+
13
20
// I'm using Rabin-Karp algorithm that uses hashing to find pattern strings in a text.
14
21
public static List <String > search (String text , String pattern ) {
15
22
List <String > result = new ArrayList <>();
@@ -73,7 +80,7 @@ public static void main(String[] args) {
73
80
74
81
System .out .print ("Enter the searching string: " );
75
82
String pattern = in .next ();
76
- // String pattern = "CDD"; testt
83
+ // String pattern = "CDD"; test
77
84
78
85
List <String > result = search (text .toLowerCase (), pattern .toLowerCase ());
79
86
You can’t perform that action at this time.
0 commit comments