Code RoomLongest border length
MediumPrep Room Coding #735

Longest border length

CodingAlgorithms & data structuresMid–Senior~20 min

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.

Implement
longest_border(s: str) → int
Examples
in["abcabc"]out3
What 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 20 min
InputExpectedGot
["abcabc"]3not run yetsample