kmp-lps-fallback-invariant

Status: IN

In the KMP implementation, the LPS array satisfies `0 <= lps[i] < i+1` for all `i`, and on mismatch the fallback `length = lps[length - 1]` guarantees forward progress — every search iteration either advances the haystack pointer or decreases the pattern pointer.

Source: entries/2026/06/06/find-the-index-of-the-first-occurrence-in-a-string-solution.md

JSON