MCPcopy Create free account
hub / github.com/EbTech/rust-algorithms / z_algorithm

Function z_algorithm

src/string_proc.rs:340–357  ·  view source on GitHub ↗

Z algorithm: computes the array Z[..], where Z[i] is the length of the longest text prefix of text[i..] that is **also a prefix** of text. It runs in O(n) time, maintaining the invariant that l <= i and text[0..r-l] == text[l..r]. It can be embedded in a larger algorithm, or used for string searching as an alternative to KMP. # Example ``` use contest_algorithms::string_proc::z_algorithm; let z

(text: &[impl Eq])

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected