Longest prefix match in text

Write codeMedium25 min

Your task

Given a text s and a pattern t (both non-empty, lowercase letters, total length <= 10^5), return the length of the longest prefix of t that appears starting at SOME position in s. Equivalently, over all start positions in s, the maximum number of leading characters of t that match. Return 0 if no character of t's prefix matches anywhere.

Examples

z_function_max_match(s: str, t: str) -> int
Example 1
Inputz_function_max_match("xabcdez", "abcx")
Output3