Service name shorthand
Your task
An internal deploy CLI lets an engineer type a shortened service name instead of the whole thing. A shorthand is any leading piece of a name, from its first character up to the entire name, and the CLI accepts a shorthand only when no other registered service starts with those same characters. You get names, the registered services in registration order. Return one shorthand per service in that same order: the shortest leading piece of that name which no other name in the list starts with. When every leading piece of a name, the whole name included, also starts some other service, that name cannot be shortened at all, so return the full name for it. Names are non empty, distinct and case sensitive. Return an empty list when names is empty.
Examples
shortest_unique_handles(names: list[str]) -> list[str]Example 1
Input
shortest_unique_handles(["api", "api-gateway", "billing"])Output
["api", "api-", "b"]Example 2
Input
shortest_unique_handles(["checkout", "chat", "cron"])Output
["che", "cha", "cr"]Example 3
Input
shortest_unique_handles(["ab", "abc"])Output
["ab", "abc"]