@@ -15,10 +15,10 @@ public static List<String> search(String text, String pattern) {
15
15
List <String > result = new ArrayList <>();
16
16
int m = pattern .length ();
17
17
int n = text .length ();
18
- int prime = 101 ; // A prime number to mod hash values
18
+ int prime = 101 ; // A prime number to mod hash values
19
19
20
- int patternHash = 0 ; // Hash value for pattern
21
- int textHash = 0 ; // Hash value for text window
20
+ int patternHash = 0 ; // Hash value for pattern
21
+ int textHash = 0 ; // Hash value for text window
22
22
int h = 1 ;
23
23
24
24
// The value of h would be "pow(d, m-1) % prime"
@@ -69,11 +69,11 @@ public static void main(String[] args) {
69
69
Scanner in = new Scanner (System .in );
70
70
System .out .print ("Enter the string: " );
71
71
String text = in .next ();
72
- // String text = "ABCCDDAEFG"; test
72
+ // String text = "ABCCDDAEFG"; test
73
73
74
74
System .out .print ("Enter the searching string: " );
75
75
String pattern = in .next ();
76
- // String pattern = "CDD"; testt
76
+ // String pattern = "CDD"; testt
77
77
78
78
List <String > result = search (text .toLowerCase (), pattern .toLowerCase ());
79
79
@@ -82,5 +82,7 @@ public static void main(String[] args) {
82
82
} else {
83
83
System .out .println ("Pattern found: " + result );
84
84
}
85
+
86
+ in .close ();
85
87
}
86
88
}
0 commit comments