Bin code prefix length
Your task
A warehouse terminal lets a picker type a bin code and stops asking for more characters the moment what they have typed can only be one bin. Given codes, return a list where element i is the length of the shortest prefix of codes[i] that is not also a prefix of any other code in the list. A prefix is at least one character long, and a code counts as a prefix of itself, so when the whole of codes[i] is the opening stretch of some other code nothing types it out on its own: return 0 for that entry. Two identical codes therefore both answer 0, and so does an empty code. Comparison is exact and case sensitive. Return one answer per code, in the order the codes are given.
Examples
bin_code_prefix_lengths(codes: list[str]) -> list[int]Example 1
Input
bin_code_prefix_lengths(["dock", "dorm", "east"])Output
[3, 3, 1]Example 2
Input
bin_code_prefix_lengths(["ab", "abc"])Output
[0, 3]Example 3
Input
bin_code_prefix_lengths(["cold-store", "cold-room", "cool-room"])Output
[6, 6, 3]