Skip to content

Commit 61f5dd3

Browse files
committed
Ensure substring is a substring in "KMP Substring Search".
1 parent 0136803 commit 61f5dd3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

algorithm/string/knuth_morris_pratt/substring_search/data.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ function randString(length) {
33
return result.substring(result.length - length);
44
}
55

6-
var string = randString(15), substring = randString(5);
6+
var string = randString(15);
7+
8+
var startIndex = Math.floor(Math.random() * 10); // Random start index from 0 to 9
9+
var substring = string.substr(startIndex, 5); // Substring of `string` of length 5
10+
711
//var string = 'abcxabcdabxabcdabcdabxabcda', substring = 'xabcda';
812
//var string = 'abcxabcdabxabcdabcdabcyiuhsiuhduiahdubhbuuabcdabcysbhbh', substring = 'abcdabcy';
913

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy