Learn
Practice
Newsletter
Resources
Resume
New
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Find the Index of the First Occurrence in a String
Bookmark
Input
Found (start)
Not found
KMP fallback
Partial match
Custom
haystack
=
sadbutsad
,
needle
=
sad
needle:
0
s
1
a
2
d
lps:
0
0
0
algo
master
.
io
Step:
Start: Find first occurrence of "sad" in "sadbutsad" using KMP algorithm.
0 / 9
Input
Found (start)
Not found
KMP fallback
Partial match
Custom
haystack
=
sadbutsad
,
needle
=
sad
0 / 9
needle:
0
s
1
a
2
d
lps:
0
0
0
algo
master
.
io
Step:
Start: Find first occurrence of "sad" in "sadbutsad" using KMP algorithm.