Back to questionsDSA Visualizers: 388 Coding Questions Repeated String Match visualizer Learn Repeated String Match with a step-by-step Strings visualizer, JavaScript source code and a worked example. Practice pattern matching.
INTERACTIVE EXECUTION STUDIOLEARN BY DOING Predict. Execute. Understand. Follow the source code, inspect live state changes, and predict the next operation before revealing it.
1 / 4 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input {
"a": "abcd",
"b": "cdabcdab"
} Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = ({
2 a,b
3 },s)=>{
4 let v="",n=0 ;
5 while (v.length<b.length+a.length){
6 v+=a;
7 n++;
8 s("Append repeat",{
9 Text:[...v],Pattern:[...b],Repeats:[n]
10 });
11 if (v.includes(b))return n
12 }
13 return -1
14 };
Execution canvas Active ChangedSTEP 1 Append repeat Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Strings · Pattern matching
Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input {
"a": "abcd",
"b": "cdabcdab"
} Execution steps Append repeat Computed output 3 JavaScript reference implementation const solve = ({
a,b
},s)=>{
let v="",n=0;
while(v.length<b.length+a.length){
v+=a;
n++;
s("Append repeat",{
Text:[...v],Pattern:[...b],Repeats:[n]
});
if(v.includes(b))return n
}
return -1
};Continue learning Practice related DSA questions in the same topic.