GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Ensure substring is a substring in "KMP Substring Search". · tangjun1990/AlgorithmVisualizer@61f5dd3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • algorithm/string/knuth_morris_pratt/substring_search
    • data.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎algorithm/string/knuth_morris_pratt/substring_search/data.js‎

Copy file name to clipboardExpand all lines: algorithm/string/knuth_morris_pratt/substring_search/data.js
+5-1Lines 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 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.