Chunk overlap length
Your task
A log shipper reads a file in chunks and deliberately re-sends a little context, so the end of one chunk can repeat the start of the next. Before appending the second chunk the stitcher needs to know how many leading characters to drop. Given two strings tail and head, return the length of the longest string that is both a suffix of tail and a prefix of head. That overlap can be as long as the shorter of the two strings, and it may be the whole of one of them. Return 0 when nothing lines up or when either string is empty. Report the longest overlap, not the first one you happen to find: for tail ababab and head ababcd the answer is 4, not 2.
Examples
overlap_join_length(tail: str, head: str) -> intExample 1
Input
overlap_join_length("2026-01-31 boot", "boot ok")Output
4Example 2
Input
overlap_join_length("heartbeat", "beat drop")Output
4Example 3
Input
overlap_join_length("gpu-fan-rpm", "temp-c")Output
0