KMP — Build LPS (π) Visualizer
Step through how the prefix function is constructed.
Python Reference Implementation
compute_lps() — live highlighted
Pattern (needle)
Quick Examples
ABABABA
AAAAAA
AABAACAABAA
A
(empty)
◀ Prev
Step ▶
Auto Play
Reset
Speed
Pattern
LPS / Prefix Function π
Narration
Click
Step
or
Auto Play
to build π. Pointers
i
(scan) and
len
(current border) illustrate the process.