Longest prefix match in text
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.
Implement
z_function_max_match(s: str, t: str) → intExamples
in
["xabcdez","abcx"]out3What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
["xabcdez","abcx"]3not run yetsample