Z-Function Ladder¶
Who This Is For¶
Use this ladder when prefix-match problems keep showing up and you want a cleaner alternative to KMP for that viewpoint.
Warm-Up¶
- build the Z array
- pattern matching through concatenation
Core¶
- prefix-match reasoning
- periodicity and borders
Repo Anchors¶
These two notes give a nice progression:
String Functionsstabilizes the Z-array mechanicsFinding Periodsturns that array into a real structure-detection tool
Exit Criteria¶
You are ready to move on when you can:
- maintain the
[l, r)invariant correctly - explain why the algorithm is linear
- use
pattern + '#' + textconfidently - recognize when the prefix viewpoint is cleaner than KMP