Longest border length

Write codeMedium20 min

Your task

A border of a string is a proper prefix that is also a suffix (proper meaning strictly shorter than the whole string). Return the length of the LONGEST border of s. For example "abcabc" has longest border "abc" (length 3), "aaaa" has length 3, and "abcd" has length 0. The empty string has border length 0. The string can be up to 10^5 characters, so aim for linear time.

Examples

longest_border(s: str) -> int
Example 1
Inputlongest_border("abcabc")
Output3