Z-Algorithm

z[i] = how far the substring at i matches the prefix, reused via a sliding [l, r) window